I’m planning to create a flow with a day calculation as condition, i.e. when difference between current date - variable_DateStored1 Greater than 7. How can i calculate this?
The story behind: My battery monitors don’t work reliable, and i want to be sure my sensors work. So when they trigger an event, i will store a timestamp (date). When i see the frontdoorsensor hasn’t triggered an event since a day, thats a reason to check the sensor.
I’ve searched in BetterLogic for date calculations, but am not able to find an answer how to do this in a Homey flow.
Maybe anyone can help?
Is it not an option to use the device trigger “a device hasn’t reported in 1 day” ?
Thank you for your quick answer. I didn’t know this was a flow trigger. I made a testflow and found that i have to filter the results: too many devices are now reported via this flow. But your idea is worth examining it.
On second hand, i don’t know how to validate the last communication event date & time. But my question stays: can i do day calculations to find out how many days differs from two date variables?
Check out better logic math.js cannot tell you the how but I thinks its possible with that function
You can do it with the
$timenow$ function into a better logic variable using the mathjs card.
Note that it’s in epoch time.
You can create another trigger to check every 3 days with a mathjs expression in the AND slot
‘If MATHJS expression is TRUE’ with a ‘$timenow$ > (yourbetterlogicvariable + 259200)
259200 being elapse 3 days in seconds