Announcement

Collapse
No announcement yet.

Query the database and assign the results to a virtual device

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

    Query the database and assign the results to a virtual device

    Hi!

    I'm using the test version
    I started to monitor the electrical power and the water flow
    The data is fine as well as the generated graphs
    I have two questions which are as follows:

    1. I wanted to automatically make a daily average of electricity consumption and assign the value obtained to a virtual device

    2. I wanted to get the daily sum of the water consumed and assign the value obtained to a virtual device.

    With all this information in the database, is it possible to do this with this plugin?



    #2
    For the average, you'll just need to write a small script that uses the native hs.SetDeviceValueByRef command to set the value of your device using the Device History "GetRangeStats" function (see the plugin documentation for more on this). However, that function only provides min, max and average, not sum. I'm certainly willing to investigate adding that to the return value (if I can do so without breaking existing scripts) or to add it as a new function in a future release.

    Comment


      #3
      Originally posted by shill View Post
      For the average, you'll just need to write a small script that uses the native hs.SetDeviceValueByRef command to set the value of your device using the Device History "GetRangeStats" function (see the plugin documentation for more on this). However, that function only provides min, max and average, not sum. I'm certainly willing to investigate adding that to the return value (if I can do so without breaking existing scripts) or to add it as a new function in a future release.
      Can I get the count (number) of samples inside a specified range time? I supose it will not be possible otherwise I would be able to get the sum ...

      Enviado do meu FRD-L09 através do Tapatalk

      Comment


        #4
        Hi

        Would anyone be able to give me an example of a script to give an average over the last hour? i have zero scripting knowledge.

        Thanks

        Comment

        Working...
        X