Announcement

Collapse
No announcement yet.

CAPI on Linux vb.net sample?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CAPI on Linux vb.net sample?

    Does anyone have examples of using CAPI on .net with Linux?

    vbscript doesnt work I guess.

    I am trying to set volume for Sonos using a script so I can run it from Alexa.

    Sonos and Amazon will have a direct control soon so maybe this is a waste of time?

  • #2
    Code:
    Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(hs.GetDeviceRefByName("Sonos Kitchen Volume"), True, "Volume (value)%", False, False)
    cc.ControlValue = 25
    Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)

    tenholde
    tenholde

    Comment


    • #3
      Originally posted by tenholde View Post
      Code:
      Dim cc as HomeSeerAPI.CAPI.CAPIControl = hs.CAPIGetSingleControl(hs.GetDeviceRefByName("Sonos Kitchen Volume"), True, "Volume (value)%", False, False)
      cc.ControlValue = 25
      Dim cr as HomeSeerAPI.CAPI.CAPIControlResponse = hs.CAPIControlHandler(cc)

      tenholde
      Thank you very much! If I want to increase the volume like clicking I tried to to this but no luck:

      cc.ControlValue = cc.ControlValue + 5

      How would I do this?

      Comment


      • #4
        Originally posted by mworsnop View Post
        Thank you very much! If I want to increase the volume like clicking I tried to to this but no luck:

        cc.ControlValue = cc.ControlValue + 5

        How would I do this?


        Code:
        Dim cc As HomeSeerAPI.CAPI.CAPIControl
                Dim cr As HomeSeerAPI.CAPI.CAPIControlResponse
                cc = hs.CAPIGetSingleControl(hs.GetDeviceRefByName("Sonos Office Volume"), True, "Volume (value)%", False, False)
                cc.ControlValue = hs.DeviceValueEx(hs.GetDeviceRefByName("Sonos Office Volume")) + 5
                cr = hs.CAPIControlHandler(cc)
        tenholde
        tenholde

        Comment


        • #5
          Originally posted by tenholde View Post
          Code:
          Dim cc As HomeSeerAPI.CAPI.CAPIControl
                  Dim cr As HomeSeerAPI.CAPI.CAPIControlResponse
                  cc = hs.CAPIGetSingleControl(hs.GetDeviceRefByName("Sonos Office Volume"), True, "Volume (value)%", False, False)
                  cc.ControlValue = hs.DeviceValueEx(hs.GetDeviceRefByName("Sonos Office Volume")) + 5
                  cr = hs.CAPIControlHandler(cc)
          tenholde
          This works great! THANK YOU!

          I have it triggering from Alexa basically saying "volume up" or down...

          Is there a way to get the the number spoken and pass to the script? Like:

          "set volume to 50" for example

          Comment


          • #6
            Nice! How did you set up the "dimmer" device? I tried but didn't get it to show up in Alexa.
            I too am looking forward to the Sonos-Alexa integration. But this would be nice in the interim...

            Comment


            • #7
              Originally posted by zwolfpack View Post
              Nice! How did you set up the "dimmer" device? I tried but didn't get it to show up in Alexa.
              I too am looking forward to the Sonos-Alexa integration. But this would be nice in the interim...
              I am using Jon00Alexa

              Its almost working right now with setting the volume

              Like "Alexa tell homeseer to set the volume to 50"

              I am putting error checking now

              Comment


              • #8
                Originally posted by zwolfpack View Post
                Nice! How did you set up the "dimmer" device? I tried but didn't get it to show up in Alexa.
                I too am looking forward to the Sonos-Alexa integration. But this would be nice in the interim...
                I made this script first and tested it entering a parm manually

                Code:
                 Sub Main(ByVal str As String)
                
                if str >= 0 and str <= 100 then
                
                Dim cc As HomeSeerAPI.CAPI.CAPIControl
                Dim cr As HomeSeerAPI.CAPI.CAPIControlResponse
                        
                cc = hs.CAPIGetSingleControl(hs.GetDeviceRefByName("Downstairs Volume"), True, "Volume (value)%", False, False)
                        
                cc.ControlValue = str
                      
                cr = hs.CAPIControlHandler(cc)
                
                hs.WriteLog("Info","The volume is set to: " & str)
                else
                hs.WriteLog("Info","Error incorrect volume: " & str)
                
                end if
                Then I installed Jons ALEXA and in the Jon00Alexa.ini I added this. Take note the ScriptParm= was added.

                Code:
                [Trigger3]
                AlexaText=living room volume
                Mode=1
                AlexaResponse=OK
                RunEvent=
                Runscript=volume.vb
                ScriptParm=
                Speak=
                SPClient=
                SpeakDevice=
                CAPI=
                Json=
                DeviceValue=
                SetDeviceValue=
                SetCapiValue=
                Delay=
                The you say

                Alexa tell Homeseer to set the living room volume to 50

                It works wonderfully!

                THANK YOU JON for the Alexa stuff and tenholde for the CAPI help!
                Last edited by mworsnop; December 18th, 2016, 02:27 PM. Reason: more info

                Comment


                • #9
                  Thanks. I was wondering if I could make a fake "dimmer" device, then copying its value into the Sonos volume. That way avoiding the "tell Homeseer" part.
                  I have Logitech Harmony (not the Homeseer plugin), so I can say "alexa turn on sonos". But that doesn't provide volume control ...

                  Comment


                  • #10
                    Originally posted by zwolfpack View Post
                    Thanks. I was wondering if I could make a fake "dimmer" device, then copying its value into the Sonos volume. That way avoiding the "tell Homeseer" part.
                    I have Logitech Harmony (not the Homeseer plugin), so I can say "alexa turn on sonos". But that doesn't provide volume control ...
                    Actually just a volume up and volume down would work. Make the 2 pseudo devices. Then on the event tell it to trigger when the device changes. That should work. I will try it and send you screen shots if you would like.

                    Comment


                    • #11
                      Originally posted by mworsnop View Post
                      Actually just a volume up and volume down would work. Make the 2 pseudo devices. Then on the event tell it to trigger when the device changes. That should work. I will try it and send you screen shots if you would like.
                      For my Sonos I created a virtual device called Sonos Volume and set it as Control Type Dim with a 0-100 range. Then I created an Event to look for a change in the value of Sonos Volume and the EasyTrigger Action to set one Device value (Virtual Sonos Volume) to another (Sonos Action). This requires the EasyTrigger and Sonos plugins, although you could emulate the Easytrigger action with a script if necessary.

                      Z

                      Of course you need to have Echo learn your virtual volume device.

                      Comment

                      Working...
                      X