Announcement

Collapse
No announcement yet.

Create a button to send an http command

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

    Create a button to send an http command

    I have a Yamaha RX series Musicast receiver. It is connnected to my local area network with a fixed IP and I can use a browser to access it's internal webserver when on my local lan. I am using HS3 Standard and I have HS3 Designer and have designed and deployed projects to our Android phones and Fire Tablets. I am using version 3.0.71 of Designer.

    Yamaha has their Yamaha MusicCast HTTP simplified API for Control Systems. I can put one of the commands into a browser and successfully control that aspect of the receivers operation. The command I have used is:
    Code:
    http://192.168.5.219/YamahaExtendedControl/v1/main/setVolume?volume=u p&step=1
    . Of course the IP is changed to match my receiver's IP address. I also changed the "&step=1" to "&step=10". I can put that in my browser (Chrome) and change the volume on my receiver up by 10 steps.

    How can I create a button in HSTouch that will send that code to my receiver?

    Any help would be appreciated.

    Chuck

    #2
    I could think of a few different ways you could do it. One would be with a volume up and a volume down button that on press calls a script (included further down). I had a quick look at the specs of that API's and it looks like in addition to passing the up/down and steps value you could pass an integer value that represents the volume. On that basis you could use a slider to control it rather than up/down buttons. To do that create a virtual device which then you could create a slider and link to it. You would then create a script (details below .vb file type) that would pass the value of the virtual device. Then create an event based on change of device value that calls the below script with "Sub or Function" set to VolumeLevel

    volume integer yes Specifies volume value Value Range: calculated by minimum/maximum/step values gotten via /system/getFeatures

    You'd have to check the above api to see what values it accepts e.g. 0-100, 0-255 or other
    Example Request http://{host}/YamahaExtendedControl/v1/main/setVolume?volume=50

    Code:
    Sub Up(ByVal parm As Object)
    hs.GetURL("192.168.5.219","/YamahaExtendedControl/v1/main/SetVolume?volume=up&step10",False,80)
    GC.Collect()
    End Sub
    
    Sub Down(ByVal parm As Object)
    hs.GetURL("192.168.5.219","/YamahaExtendedControl/v1/main/SetVolume?volume=down&step10",False,80)
    GC.Collect()
    End Sub
    
    Sub VolumeLevel(ByVal parm As String)
    Dim volume = hs.devicevalueex("1016")
    hs.GetURL("192.168.5.219","/YamahaExtendedControl/v1/main/SetVolume?volume="&volume,False,80)
    GC.Collect()
    End Sub
    in the above change 1016 for the reference ID of the virtual device you created. Make sure you virtual device is also set to 0 decimal places

    Comment


      #3
      Thank you so much for your help. I will give this a try tonight. I will let you know how it goes.

      Chuck

      Comment

      Working...
      X