This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
How to calculate a duration
larsmachiels
Member
I would like to calculate how long a window was open with the use of a contact sensor. When the windows opens it should store the time in a (time)variable. When the windows closes it should calculate the duration (closing time minus the start time).
Anybody any Idea? Thanks in advance.
Anybody any Idea? Thanks in advance.
Comments
math.eval(460 V * 20 A * 30 days to kWh)
should give: 6624 kWhso you might build further on this?
When using the countdown app, use a very high counter. Then you could count the time.
You could start indeed with a very high counter and then retrieve (with the global tags) the remaining seconds and then do some calculations.
I could make a 'CountUp' variant as a separate app, that shouldn't be too hard ( at least much easier than change the current countdown app design). Would this something more than a handful of people are interested in?
Flow 1: Triggerflow
IF "conditions met" THEN "Set Better Logic variable X = true" AND trigger Flow 2:
Flow 2: Count seconds
IF "This flow is triggered" AND "Better Logic variable X = true" THEN "increment Better Logic variable Y with 1" AND "Trigger flow 2" (delayed 1 sec)
Flow 3: Stopflow
IF "conditions not met anymore" THEN "Set Better Logic variable X = false"
Don't know if the precision is like an atomic clock, but for daily use, it might be enough?
You probably don't need seconds, this flow gives you window-open minutes in a better-logic variable
Everyone thanks again for all the help.
I BTW use the Xiaomi Zigbee contact sensor which only costs +/- € 10,00 and works perfectly well.