Vacuum Maintenance
Posted on 2024-03-30 in misc • 4 min read
Introduction
We have two, basic, Eufy robovacs in our house. I have them set on a schedule to run (well, it's a little more complicated than that, but let's just go with that), but that's about the only automation I have with them. I decided I wanted to keep track of the time things were active, and then send alerts when maintenance is needed. The three maintenance items are: Empty the bin, change the side brush, clean the roller brush.
Obviously I can just look at the things and determine if they need changed, or cleaned or whatever. But that's not nerdy enough for me. This is the story (and howto) of what it took to make this work for me.
Setup helpers
The stats need to be based on the time that we last did the maintenance. To do this, I created a datetime helper that we update when we perform the maintenance. So everything I want to track gets it's own datetime helper.
Note
I am naming them with the pattern input_datetime.<vacuum>_<maintenance item>. This will be important later, because the script is using jinja to replace those two components.
Stats Plugin
With the datetime helpers, I can then create a history stats entity for each of the helpers. In the example below, I have done this for one of the vacuum's side brushes.
In this case, I want to track the amount of time "Rory" is in "cleaning" state, which is when it is actually doing the vacuuming. The start time is the state of the helper we made above, and the end is the current time.
Alerts for maintenance
I actually haven't completed this part yet, because I'm still trying to narrow down the times that I want to alert. But the basic idea here is that I will create an automation to check the time that each of the components has been used. And then, with a number helper probably, I'll send an alert when it's greater than the amount of time that I want. So if I figure that I need to empty the bin after 3 hours of running, I'll just set the trigger to be when the history_stats sensor is greater than 3 hours.
What now?
Generally, I have used NFC tags to kick things off if I don't have a direct way to sense it; however, I don't want to make a tag for every maintenance task. So what I decided to do is create an NFC tag per vacuum. Then, when that is scanned, it'll run a script that will send off a notification to my phone where I will then pick which maintenance action I took. Currently it fires every time you scan the tag, but technically I could figure out if there is only one maintenance task due for the vacuum, and only present it when there are choices, but for now I'm keeping it "simple"
The script
With the helper and stats components in place, we now need a way to tell Home Assistant that we have performed the maintenance. I chose to do this via a script. It's easier to call scripts directly from iOS shortcuts. This part was the most complicated because there were some new things I had to figure out.
When the script is executed, it will send the notification to my phone. It'll then wait (30 seconds) to get a response. It will then determine which action to take based on the response selected in the notification. So if I run the script, get the notification, and choose "Empty bin" from the selection, it'll perform the action on the "*_dust_bin" datetime helper.
Note
On the iOS notification, you have to hard/long press the notification to get the actions to pop up. There is no indication that the actions are there. It's kind of stupid, but that's iOS "genius" behavior.
Note
The way this is written, the script must explicitly be given a vacuum name in the call. I'll cover that in the next section.
iOS Settings
On the iOS side, I create a shortcut and an automation to get around iOS being stupid.
Note
You could use an NFC tag in Home Assistant, and just use that in a trigger in an automation that calls the script. I don't like the way that works, because you have to have your phone unlocked, and then confirm that you are opening it. So my work-around is to to create a shortcut that does the work, and an automation to kick off the shortcut when the NFC tag is scanned.