I’m new to HA and a little puzzled what can be done and how. I’d like to automate my Roborock robot vacuum to clean a room if it has not been cleaned for three days. I started developing bottom up and configured template sensors for rooms. I had in mind that I could store timestamp of the last time of the room has been cleaned in the template sensor attributes and change the timestamp next time when the robot cleans the room. The problem is that it seems impossible to change the template sensor attribute via automation.
I would like also to automation to be just date dependent instead of hourly comparison. I mean the automation would just check if the room has been cleaned during the last three days and if not, then executing the script in certain time. Also I would like it to collect all the rooms to a list and clean them on the same action during the day so the robot would not need to run back to dock and start doing vacuuming all over again.
Now I’m a little bit lost how I could achieve this kind of automation when my initial plan has failed. Any tips how to pick another route on my plan?
The state loads before the attributes, so you need to either do your calculations in both or supply a default so that the state doesn’t error out. Also your sensor will be static because days_since is static and everything that follows is built on that.
What data does your vacuum supply that could be used to define the last_cleaned variable? For example, does it have a room id that changes when it completes a room which you could use to set the value of a helper of template sensor?
In your automation, you are performing a lot of pointless calculations. Once you have selected for the state being ‘on’, there is no reason to run multiple expand() and map() functions. If you meant to use that data later, you should use trigger variables to store it so it is available throughout the whole automation and doesn’t need to be recalculated.
Thanks for the reply! Yes, the sensor timestamp is currently static for only development purposes. Would like it to be dynamic but currently I have no idea how I could achieve it. The vacuum cleaner only provides timestamp of last cleaning end but does not provide room id’s or anything else usable. But the cleaner could be started with the following automation configuration example:
I had in mind that the those room id’s could be used again later in automation to trigger new timestamp for the room template sensors. Just don’t know how to implement it.
The variables suggestion looks nice. Have to dig in little further as this is the first time I see use of them.