How to get Time Data from Status on DGlux?
-
I need help to get some data on DGLux.
I want to know if it's possible to show how long a Door(for example) stays open, and how long it stays closed, knowing that i just have a binary contact that tells me only if it's open or closed.I want to show this information for the client in a "pie chart".
Thanks!
-
Hi Tobias!
It is certainly possible! Unfortunately, it's not as easy as a click and drag. There is not a direct way to query our statistics engine from DGLux for binary points.
To do this, you'll want to use a Meta point in Mango to generate the information you're interested in. The meta point would look something like this, with p being the varName of the Door point in the script's context, running every minute (you can use the cron selector, or enter "0 * * * * ?":
statistics = p.past(MINUTE); if(statistics.data[0].value == true) return statistics.data[0].proportion; if(statistics.data.length < 2) return 0; return statistics.data[1].proportion;
Now we've got a data point giving us minute resolution (finer resolutions can be achieved in modifying the cron and call to past()) for the binary point. This data point will have the meaning "Proportion of minute open" and will be numeric.
From DGLux, you can query this point to get the values into a table. Then, you can bind the value column to a binding column on another sheet. You'll want to use the Sum rollup. Create another binding column on that table bind the value column again, and use the Count rollup. Create a formula column and have its formula be "return countColumnName - sumColumnName". Now you can bind these columns (sum and the forumla columns, click and drag the column headers) to a pie chart to get minutes in each state. If you wanted it to be a proportion, you could make formula columns and divide by the count. If you do not see anything in the sheet with the binding columns after binding (first step on the second sheet), click the add row button.
You can use the meta point's history generation function to get this to work even for your past point values.