Announcement

Collapse
No announcement yet.

Using API to change Status Only device

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

  • joegr
    replied
    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.

    Leave a comment:


  • paul
    replied
    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"

    Leave a comment:


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

    Leave a comment:


  • joegr
    replied
    Okay, so it turns out that you can update a status only device with:
    JSON?request=setdevicestatus&ref=306&value=40.3

    Leave a comment:


  • joegr
    replied
    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"
    Works.

    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?

    Leave a comment:


  • zwolfpack
    replied
    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!

    Leave a comment:


  • paul
    replied
    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:

    Code:
    2018-07-07 10:00:27,364 DEBUG: http://home.myhsserver.ca/JSON?&request=setdeviceproperty&ref=569&property=NewDevValue&value=0
    2018-07-07 10:00:28,384 DEBUG: http://home.myhsserver.ca/JSON?&request=setdeviceproperty&ref=569&property=ChangedValueORString&value=TRUE
    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.

    Leave a comment:


  • zwolfpack
    replied
    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.

    Leave a comment:


  • paul
    started a topic Using API to change Status Only device

    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:

    http://home.myhsserver.ca/JSON?&request=controldevicebylabel&ref=563&label=Open

    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?

    regards,

    Paul
Working...
X