I’m having the following project idea in order to protect the battery of my stick vacuum cleaner (the battery would get warm during usage and charging warm lithium batteries is far from ideal): on the charger I have a window contact sensor (binary_sensor.vacuum_charger_contact) and a magnet on the vacuum to detect when the vacuum is not in the cradle. A socket sits between the charger and the power grid (switch.vacuum_plug).
The automation idea is something like this:
when the vacuum is removed, start counting the time (I’m guessing history stats would help me)
when the above counter reaches 2 minutes, turn off the socket (if the vacuum was only used briefly, the battery most probably is still cold)
when the vacuum is back in its cradle, start a timer that has the same length as the above counter and reset the counter
to avoid any ridiculous situations, if the counter is longer than 30 minutes, keep the timer at 30 minutes
What I cannot figure out on my own is how to set up the history stats sensor. The timer will probably be started with “Timer: Start”, but I’m not 100% that this is the right way.
Thanks for any input and I hope someone might also benefit from my idea!
Probably I should have left that detail with 2 minutes out. Basically, I want the vacuum cleaner to cool down before it starts charging. The cooldown time shall be just as long as the working time, but not longer than 30 minutes.
I am assuming the cooldown time starts the moment the vacuum cleaner is put back in its cradle (I’m putting it back in the cradle right after usage).
I hope this clears things up a bit.
When you take the vacuum out of the charging station set a Date/Time helper to the time at that moment by using the automation trigger above.
Then, when the vacuum is replaced, calculate the difference between now() and the Date/Time helper.
Next, set a timer to the value of the minimum value between the number (in seconds) above and 30 x 60 seconds.
When the timer expires (it helps to protect against restart issues, etc.) run your switch_turn_on action - if it’s still on, because it was never turned off, no harm done: turning a plug on again when it’s already on doesn’t do anything.