Announcement

Collapse
No announcement yet.

Open URL via Event Action

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

    Open URL via Event Action

    Hi,

    I am relatively new to HomeSeer and this forum and I'm not sure this is the correct place to ask this.

    I am trying have an event control a Control By Web device. To do this, I need the Action of the event to open a URL, for example; http://192.168.92.25/state.xml?relay9State=1.

    Could someone please help me with this? If it requires I script, I am not a programmer so I would ask for specific help.

    Thanks,
    Dennis

    #2
    Originally posted by dennis48755 View Post
    Hi,

    I am relatively new to HomeSeer and this forum and I'm not sure this is the correct place to ask this.

    I am trying have an event control a Control By Web device. To do this, I need the Action of the event to open a URL, for example; http://192.168.92.25/state.xml?relay9State=1.

    Could someone please help me with this? If it requires I script, I am not a programmer so I would ask for specific help.

    Thanks,
    Dennis
    To do this it likely needs either a HTTP Post or Get. A way to test this is to put that URL in a web browser and if you go to the link and it works then it will be OK with a Get. If so the script can be quite simple as HS already has options to do this for you and you might not need a full script (a single line script entry may do) so try running this and see how you get on;

    &hs.URLAction("http://192.168.92.25/state.xml?relay9State=1", "GET", "", "")

    Comment


      #3
      mrhappy,

      ...see how you get on;
      I get it (ha, ha)

      &hs.URLAction("http://192.168.92.25/state.xml?relay9State=1", "GET", "", "")
      Worked perfect, thank you so much mrhappy.

      I entered your suggested command in "Execute immediate script command: " under Run a Script... Could I have also added the command in a text file and pointed to the txt file?

      I get so excited when these things work.

      Dennis

      Comment


        #4
        Originally posted by dennis48755 View Post
        mrhappy,


        I get it (ha, ha)



        Worked perfect, thank you so much mrhappy.

        I entered your suggested command in "Execute immediate script command: " under Run a Script... Could I have also added the command in a text file and pointed to the txt file?

        I get so excited when these things work.

        Dennis
        Yes you can put this in a script without issue, just for a non-immediate command you can drop the leading & (and I would recommend using .vb script files rather than .txt). As an example if you create a virtual device in the UI it will default to an on/off set of buttons with a value of 100 being on an 0 being off.

        You can then create an event that triggers whenever this device changes value, you can then run a script that runs with this event. In this script you can do something like;

        Code:
        Sub Main(ByVal Parms As Object)
        
        Select Case hs.devicevalueex(1234) 'change this to the device reference of your device
        
        Case 0 : hs.URLAction("http://192.168.92.25/state.xml?relay9State=0", "GET", "", "")
        Case 100 : hs.URLAction("http://192.168.92.25/state.xml?relay9State=1", "GET", "", "")
        
        End Select
        
        End Sub
        And you will hopefully find the output turns on/off depending on your device in HS.

        Comment


          #5
          Thanks again mrhappy.

          It took me a while to figure out the device reference value in your script, then I finally came across the Reference ID field under the Devices Advanced tab.

          I appreciate all your help.
          Dennis

          Comment


            #6
            I've been trying to use this method to run my controlbyweb relays and most times it works but I still keep getting an error in the log.
            In my vb.net script I use:
            hs.URLAction("http://ipaddress.com:80XX/state.xml?relay1State=1", "GET", "", "")
            and it gives me error in log:
            In URLAction GET: The server committed a protocol violation. Section=ResponseStatusLine

            Is there any way to modify (hs.URLAction) to properly deal with the .xml file format?
            Last edited by PeterRoelofs; January 28, 2018, 03:34 PM.

            Comment


              #7
              For those interested https://forums.homeseer.com/forum/hs...olbyweb-plugin

              Comment

              Working...
              X