Announcement

Collapse
No announcement yet.

Device value not shown correctly

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

    Device value not shown correctly

    I've added Corona statistics for my municipality as virtual devices in HS4 beta 4.0.3.0. Data is read from JSON raw data using a VB script run by a timed event, and set to the virtual devices. On the front panel they're shown like this:

    Click image for larger version

Name:	2020-03-19 14_11_20-Devices.png
Views:	108
Size:	53.4 KB
ID:	1371110

    I've added all three devices as monitored devices in Device History. But all three are charted like this:

    Click image for larger version

Name:	2020-03-19 14_13_22-Window.png
Views:	79
Size:	9.8 KB
ID:	1371111
    The charts for all three devices are identical. Any idea what the problem is here?

    #2
    Very strange. Can you grab a screenshot of the "Confirmed" feature details screens?

    Comment


      #3
      Not quite sure if this is what you mean with "feature details", but I'm just posting the device configuration for the "Confirmed" virtual device. I've taken the screen shots from the "/deviceutility" page still available in HS4. Let me know if you need anything else.

      Click image for larger version

Name:	2020-03-19 15_17_19-Window.png
Views:	90
Size:	67.0 KB
ID:	1371135
      Click image for larger version

Name:	2020-03-19 15_17_44-Window.png
Views:	77
Size:	35.8 KB
ID:	1371136

      Comment


        #4
        If it's relevant, here's a snippet on how the values are set in the script:

        Code:
        For i As Integer = 0 To json("cases").Count - 1
            If json("cases")(i)("name") = "Vestland" Then
                hs.SetDeviceString("504", json("cases")(i)("confirmed"), False)
                hs.SetDeviceValueByRef("504", confirmed, True)
                hs.SetDeviceString("506", json("cases")(i)("dead"), False)
                hs.SetDeviceValueByRef("506", confirmed, True)
                hs.SetDeviceString("507", json("cases")(i)("recovered"), False)
                hs.SetDeviceValueByRef("507", confirmed, True)
            End If
        Next
        The data is read from this endpoint: https://www.vg.no/spesial/2020/coron...able-overview/

        (Kudos to Moskus for supplying the script for this)

        Comment


          #5
          It looks to me like the chart is working perfectly. The "Value" is what is shared with the plugin by HomeSeer and what drives everything, and it's clearly "1704" which matches the graph.

          Comment


            #6
            Bah... Ok, I see a problem here now. My rewrite of the script was way off... Setting the device values like this works fine in Device History:

            Code:
            For i As Integer = 0 To json("cases").Count - 1
                If json("cases")(i)("name") = "Vestland" Then
                    hs.SetDeviceValueByRef("504", json("cases")(i)("confirmed"), True)
                    hs.SetDeviceValueByRef("506", json("cases")(i)("dead"), True)
                    hs.SetDeviceValueByRef("507", json("cases")(i)("recovered"), True)
                End If
            Next

            Comment


              #7
              Ah - I see your problem. You're setting the Value to "confirmed", but you're setting the string to the "Vestland" case{confirmed} value. So the chart is charting all confirmed in Norway, but the string you're displaying is only those in Vestland. Change your "SetDeviceValueByRef" statements to also use json("cases")(i) variables and it will work.

              If you want to correct things, use the "Device String" values in the table to update the value using a SQLite editor on the db3 file (but stop the plugin first!).

              Comment


                #8
                Good idea updating the SQLite db. Thanks a bunch for your help!

                Comment

                Working...
                X