# Speaking elapsed hrs:mins between two times?

Use Case: Dryer stops. Want to announce periodically that the dryer has completed (and will use a motion sensor in the laundry room to know when somebody went in there - and then stop the announcements)

That's easy enough to do with a rule, triggered by the "Better Laundry" app and a repeat loop w/delay until the motion sensor goes off.

But -- It'd be helpful to also announce that it finished "xx minutes ago, or yy hours and xx minutes ago"

Surely someone has figured out how to do the math to create "hours / minutes / seconds" variables from a "date/time x" minus "date/time y"?

Am assuming someone has the "formula" (gonna be multiple steps, I realize) -- and can cut/paste how to do it?

You could do just minutes by setting a variable and initializing it to zero when the laundry finished. Then each time your repeat loop runs increment the counter by how ever many minutes you are waiting per loop and pass that variable in your announcement.

2 Likes

Good idea. That may be where I go. It works for a single device easy enough.

I didn't get into all the complexity planned (was keeping it simple in description) -- but am ultimately wanting to do some more complicated work where both washing machine and dryer are considered (eg, if both have finished, or just one, but the other is still running) and being able to announce how long it's been since each has finished. That's harder to do without being able to calculate a start/end delta for each. "The washer stopped 10 minutes ago, the dryer stopped 20 minutes ago"

I may just do them with several rules. One to loop and increment a washer-stopped-elapsed variable, and the other to loop and increment a dryer-stopped-elapsed variable.

Then the "is finished" rule for speaking is a different rule, that just queries the latest version of the variables.

** Update: For now, for testing theory - have created two rules - each to increment a "minutes since finished" variable -- and stop it when motion is detected (or as a fall-back, if the device starts up again)

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.