Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
Totalized/Sum Binary Point per Day
-
I'm trying to sum a binary point which represents run status (variable = runs) of a pump. 1 = pump is running. 0 = pump is stopped.
I'd like to calculate the total number of starts during the day. This new variable is a numeric data type.
Based on my search on the forums and previous help I've received, the best I could come up with is either this:
return point.previous(DAY).sum;
Or this:
return point.past(MINUTE, 1440).sum;
With a cron pattern of: 57 59 23 * * ?
When I generate the data, I get a notification that 5 updates were created.
However, all the values are 0.
I suspect my problem has something to do with the fact that I'm attempting to count a binary point.
-
Hi Mihai,
Binary points return StartsAndRuntimeList objects, not AnalogStatistics objects. i would encourage you to check out
print( point.past(DAY) );
and use the cron you have. previous() is quantized, so you're asking for the day before the day it's running on in that setup.The contextual help menu for Mango JavaScript is in Mango and also here: http://help.infiniteautomation.com/support/solutions/articles/14000022520-about-mango-java-script
Of interest is probably the
.count
property, which if you're logging your binary on change, is probably 2x the value you are looking for or 2x+1. You can also get the data specifically for the true or false states in the.data
list property of the StartsAndRuntimeList -
I got this to work:
return point.past(MINUTE, 1440).get(true).starts;
Thanks.