Announcement

Collapse
No announcement yet.

History not seen/logged when using JSON to update a virtual device value

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

  • History not seen/logged when using JSON to update a virtual device value

    I have a Wifi sensor updating a virtual device value using the following web server JSON call:

    http://192.168.0.208/JSON?request=se...ef=134&value=5

    The value of the virtual devices changes in HS, but the value changes are not seen/logged by the device history plugin.

    Any wisdom on how to get this working?

    Thanks,
    TJ



  • #2
    Can you provide some more info? Please start with the info in this thread: "Having problems? Follow these steps first."

    Comment


    • #3
      Hi Shill.

      Below is my HS version.
      Feb-10 8:42:37 AM Startup ************************************************************ ********************
      Feb-10 8:42:37 AM Startup HomeSeer version 3.0.0.500 Edition: HS3 ZEE S2 Starting Now
      Feb-10 8:42:37 AM Startup ************************************************************ ********************
      Attached is the plugin log which I believe gives you the version.

      The device is "Front Yard Lights Voltage" #133

      During this log I had the sensor send a couple updates to HS using the JSON:
      http:/192.168.0.208/JSON?request=setdeviceproperty&property=NewDevValue&ref=134& value=

      I see the value of the device changing in HS, but when I go to the device history chart its blank.

      Here is detailed information about the device:
      {"Name":"HomeSeer Devices","Version":"1.0","Devices":[{"ref":133,"name":"Front Yard Lights Voltage","location":"","location2":"","value":0,"status":"Ou tput 0 Volts","device_type_string":"","last_change":"\/Date(1549641024498)\/","relationship":0,"hide_from_view":false,"associated_de vice s":[],"device_type":{"Device_API":0,"Device_API_Description":" No API","Device_Type":0,"Device_Type_Description":"Type 0","Device_SubType":0,"Device_SubType_Description":""},"d evi ce_image":"","UserNote":"","UserAccess":"Any","status_image" :"images/HomeSeer/classic/electricity.gif","voice_command":"","misc":12560,"interface_ name":""}]}

      I have a suspicion the issue has to do with the device being "Status Only" (not control), but I am not sure.

      Thanks for taking a look at this.
      TJ
      Attached Files

      Comment


      • #4
        Hi Shill,

        I figured out that if I uncheck "Status Only Device" of the device
        AND
        Set the device value Status-Control type to "Both"
        AND
        Use the JSON call
        http://192.168.0.208/JSON?request=co...ref=133&value= (instead of http:/192.168.0.208/JSON?request=setdeviceproperty&property=NewDevValue&ref=134& value=)
        I then get history and charts.

        The down side of doing it that way is that is that HS then shows control buttons on the device when it really only is a status devices.

        I guess the history plugin only works for control type devices and not status only devices?

        Thanks,
        TJ

        Comment


        • #5
          That does appear to be the case. The plugin works by subscribing to a specific event type (VALUE_CHANGE) that HS advertises, and that callback isn't raised when using "SetDeviceProperty" but rather only when using "ControlDeviceByValue", and the latter can't be used on a status only device.

          Comment


          • #6
            rjh Another one

            Comment


            • #7
              Sounds like you need a JSON call like "/JSON?request=setdevicestatus

              Setting the status using the property set command is a bad idea since that is not an API. Other things need to happen when you set some of the device properties, this is why events don't fire. But firing them would be a mess as they are fired elsewhere so we would get double events. I would have to look at each property that was being set and handle each one as a special case. Better to add an API for this.

              Might be a good idea to add the ability to run "HS" commands from JSON, then you can just call hs.setdevicestatus which is an API. You can already call plugin functions from JSON, so calling "HS" commands would not be hard to add.
              website | buy now | support | youtube

              Comment


              • #8
                Thanks!!

                Comment


                • #9
                  And I'd need it to come through HSEvent to capture it, but that might suddenly start flooding others with events they weren't expecting... so maybe we need a new HSEvent for VALUE_STATUS_CHANGE? (which would be everything VALUE_CHANGE sends today plus these, hopefully)

                  Comment


                  • #10
                    Originally posted by rjh View Post
                    Sounds like you need a JSON call like "/JSON?request=setdevicestatus
                    so this would looks like JSON?request=setdevicestatus&ref=9750&value=12 .

                    Comment


                    • #11
                      You can change the string status on a device and/or the value. Are you just changing the string that is displayed? There is a separate event for that. If you are changing the value, then the normal value change event will need to be triggered as there may be other plugins that want to see changes on any device, so we cannot hide specific ones. Is this device going to be changing often? Most plugins do not need to register for the Value Change callback as they only need to deal with their own devices.

                      Originally posted by shill View Post
                      And I'd need it to come through HSEvent to capture it, but that might suddenly start flooding others with events they weren't expecting... so maybe we need a new HSEvent for VALUE_STATUS_CHANGE? (which would be everything VALUE_CHANGE sends today plus these, hopefully)
                      website | buy now | support | youtube

                      Comment


                      • #12
                        Its possible to set both the display string and the value, so this call would probably allow the setting of either one or both. For status only devices, they may not have any status pairs assigned so setting the device string might be necessary so only a number is not displayed.

                        Originally posted by MattL0 View Post

                        so this would looks like JSON?request=setdevicestatus&ref=9750&value=12 .
                        website | buy now | support | youtube

                        Comment


                        • #13
                          Originally posted by rjh View Post
                          You can change the string status on a device and/or the value. Are you just changing the string that is displayed? There is a separate event for that. If you are changing the value, then the normal value change event will need to be triggered as there may be other plugins that want to see changes on any device, so we cannot hide specific ones. Is this device going to be changing often? Most plugins do not need to register for the Value Change callback as they only need to deal with their own devices.
                          The purpose of this plugin (of which I'm the author) is to record the historical values of all monitored devices, so I do in fact register for Value Change and if this new call changes a device's value, I would need to know about it since my customers (as above) want the status recorded over time.

                          Comment


                          • #14
                            Hey Guys,
                            Thanks for looking into this.
                            I am pretty new to HS. I just converted from Vera.Just got so tired of its instability.

                            The reason I am asking for this, is I have created a lot of my own sensors using the Particle Photon. Those sensor reported their values to Vera through HTTP JSON calls.
                            I am now modifying them to do the same with HS.
                            In HS I created "Status Only" virtual devices" for these. For example, temperatures, voltages, etc. I just want HS to display their value and be able to graph some of them over time. HS does not need to control them so I dont really need a "Control" device.

                            For the reasons mentioned before, for now I have changed them to "Control" devices so that the history is saved and events can be fired from their value changes when they call JSON controldevicebyvalue.

                            However, with this setup HS shows the device can be controlled, when it cant.

                            I dont know if it would be appropriate or not, but what would solve this issue for me is if there was also a device control type of "None" (instead of text box, drop list, slider, color picker). When a device of type control had this property set to "None" HS would then simply not display any type of control for it, but it could still be controlled through JSON and other internal methods.

                            Thanks,
                            TJ

                            Comment


                            • #15
                              Originally posted by TjTrolinger View Post
                              Hey Guys,
                              Thanks for looking into this.
                              I am pretty new to HS. I just converted from Vera.Just got so tired of its instability.

                              The reason I am asking for this, is I have created a lot of my own sensors using the Particle Photon. Those sensor reported their values to Vera through HTTP JSON calls.
                              I am now modifying them to do the same with HS.
                              In HS I created "Status Only" virtual devices" for these. For example, temperatures, voltages, etc. I just want HS to display their value and be able to graph some of them over time. HS does not need to control them so I dont really need a "Control" device.

                              For the reasons mentioned before, for now I have changed them to "Control" devices so that the history is saved and events can be fired from their value changes when they call JSON controldevicebyvalue.

                              However, with this setup HS shows the device can be controlled, when it cant.

                              I dont know if it would be appropriate or not, but what would solve this issue for me is if there was also a device control type of "None" (instead of text box, drop list, slider, color picker). When a device of type control had this property set to "None" HS would then simply not display any type of control for it, but it could still be controlled through JSON and other internal methods.

                              Thanks,
                              TJ
                              Another option would be to simply stop FORCING value status pairs. If I delete them or set them to "status" instead of "both" or "control", that means I don't want to see them. Instead, HS decides to show On/Off buttons anyway.

                              Comment

                              Working...
                              X