No announcement yet.

Using API to change Status Only device

  • Filter
  • Time
  • Show
Clear All
new posts

    Using API to change Status Only device

    I have several virtual devices that I want to use purely as Status indicators within HSTouch. The basic command I'm using to update the status of the devices within HS is:

    However, I don't want these devices to be manually changable directly from within HSTouch nor the Web UI. Initially I tried checking "Status Only Device" on the device to get rid of the change buttons. However, when I do that, the API 'controldevicebylabel' stops working.

    So then I unchecked it again, and tried hiding the devices from view. Except when I do that, the devices no longer become selectable to take the status from for HSTouch elements (ie the elements that I want to use to view the status of those devices).

    I saw a few posts about trying to use setdeviceproperty but could not find adequate documentation around that option nor an example in the forum that actually worked to change the status and it's associated icon.

    Any suggestions?



    The only way I've found to control status-only devices is through scripting. So I create an event to set each state for each device, each of which is a immediate one-line script. These events are called from the API instead of controlling the devices directly.

    No idea why the API doesn't allow direct control.


      Ok, I've figured it out, based on another thread. If I use setdeviceproperty by value I can make it happen. I tried using NewDevString, but that just changed the Status string without updating anything else (graphic value, value, hstouch). But NewDevValue updated the value and graphic appropriately.

      However, then HSTouch wasn't recognizing the change. That was fixed by setting ChangedValueORString to TRUE on the device. So, basically I had to do:

      2018-07-07 10:00:27,364 DEBUG:
      2018-07-07 10:00:28,384 DEBUG:
      First one, then the other. And everything updated.

      I've tested this to work on both status only devices, and Status only values on regular devices.


        Very nice! Tested and it works exactly as you say. Without the 2nd request the update doesn't register in HSTouch, but with it it changes immediately. Thanks!


          I am able to get the above to work with integers.
          "GET /JSON?request=setdeviceproperty&ref=306&property=NewDevValue& value=40 HTTP/1.1\r\nHost: 192.168.1.xx\r\nConnection: close\r\n\r\n"

          I can't get it to work with values with a decimal point.
          "GET /JSON?request=setdeviceproperty&ref=306&property=NewDevValue& value=40.3 HTTP/1.1\r\nHost: 192.168.1.xx\r\nConnection: close\r\n\r\n"
          Results in { "Response":"error, setting device property:Input string was not in a correct format." }

          Any thoughts?


            Okay, so it turns out that you can update a status only device with:


              My only concern there is does 'setdevicestatus' change the string only and not the value? (I don't know the answer offhand).


                If that's the case, and you want to try changing the value, what happens if you put the value in quotes? ie.

                JSON?request=setdeviceproperty&ref=306&property=NewDevValue& value="40.3"


                  Originally posted by paul View Post
                  My only concern there is does 'setdevicestatus' change the string only and not the value? (I don't know the answer offhand).
                  It changes the value, and events based on value change do work.