Count and show Time since Washing machine is running

Hello,

I have a plug at my washing machine to show, that the machine is running.
This icon is normally green, when the machine works, it is red.
Now I want to show the time in habpanel, since the machine is running in the format HH:mm.
When the icon becomes green, the counter should show 00:00.

I tried to find a solution, but without success.

I hope you can help?!

Thanks

This is going to take some Rules and some Math.

  • I’d write a Rule that triggers when the Switch turns ON.

  • Create a Number Item to store the Number of minutes and reset this Item to 0 when the Rule triggers.

  • Create a Design Pattern: Looping Timers that runs every minute and adds one to the Number Item.

  • Create a JS transformation that converts the number of minutes to HH:MM format to be used in the Item’s label.

  • When the Switch turns OFF, cancel the looping timer.

thank you very much.
I am a newbie, can you please explain it a little bit more?

I’d write a Rule that triggers when the Switch turns ON.

Create a Number Item to store the Number of minutes and reset this Item to 0 when the Rule triggers.

In the Rule

MyNumberItem.postUpdate(0)

where MyNumberItem is the name of the Number Item you created.

Create a Design Pattern: Looping Timers that runs every minute and adds one to the Number Item.

Read the design pattern and come back with specific questions.

Create a JS transformation that converts the number of minutes to HH:MM format to be used in the Item’s label.



When the Switch turns OFF, cancel the looping timer.

See the design pattern