Announcement

Collapse
No announcement yet.

Question about JSON request and devicevalue

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

    Question about JSON request and devicevalue

    I wrote an app for ESP32 Arduino which uses the json request : json?request=controldevicebyvalue&ref=2755&value="+ voltage_value;

    The value posts a decimal to the device correctly as below.
    When I pull the devicevalue through vbscript I only get the integer value (4) and not the 3.64

    I am using hs.DeviceValue(2755)

    Any thoughts:

    Will



    Click image for larger version

Name:	value.JPG
Views:	204
Size:	16.7 KB
ID:	1480751


    #2
    You should be using hs.DeviceValueEx(2755) which returns a double.

    hs.DeviceValue(2755) will return an Integer.
    Jon

    Comment


      #3
      Thanks. I did try that and it returns the integer 4 not the decimal 3.64. Any thoughts. BTW 2755 is a child of the device

      Comment


        #4
        hs.DeviceValueEx(2755) is the correct scripting command to use. Try a simple script to read this in the hs log.

        Jon

        Comment


          #5
          Great Idea. Ill try that. TY

          Comment


            #6
            As it turns out. I was using the json request to store a control value (change the state of the device), that has to be an integer. I looked in the json documentation and it does not appear a manner in which to change the device value , but rather the device state. So i did a work around by creating a range of values 0 to 25000 and simply changed the state from the arduino IDE sketch by using the product of the decimalized volatage and 1000 and then I convert back to decimal by dividing by a 1000 on the other end. Crude but works.

            Will

            Comment


              #7
              You can set a device value via JSON but I'm not sure its documented correctly:

              JSON?request=setdevicestatus&ref=2755&value="+ voltage_value;
              Jon

              Comment


                #8
                Thanks ill give that a try

                Comment

                Working...
                X