I always launch my autonomous home hoover from home assistant (roomba). I would like that every time I launch it, a variable is incremented so that when this variable is 5, it warns me that I have to empty the vacuum cleaner tank. How can I create a variable and add 1 to it at each hoover output.
You could do an automation for when it docks or starts cleaning to increment the number, something like:
description: ""
mode: single
trigger:
- platform: state
entity_id:
- vacuum.roomba
attribute: status
to: Cleaning
condition: []
action:
- service: input_number.increment
target:
entity_id: input_number.hoover_ran
data:
amount: 1
Of course, you would have to create the input_number helper, input_number.hoover_ran.
Then, probably a button to set it back to zero when you do empty it.
First I have created a helper:
input_number.robot_aspirador_numero_de_limpiezas
And then an automation that runs whenever the hoover goes into cleaning mode.
alias: Acción - Rogelia - Sumar una limpieza - Al limpiar
description: ""
trigger:
- platform: state
entity_id:
- vacuum.roborock_s5_28f2_robot_cleaner_2
to: cleaning
from: null
for:
hours: 0
minutes: 5
seconds: 0
condition: []
action:
- service: script.accion_rogelia_sumar_una_limpieza
metadata: {}
data: {}
mode: single
and finally a script that checks the value of the helper, if the value is lower than 4 it increases it, but if it is higher it warns me.
alias: Acción - Rogelia - Sumar una limpieza
sequence:
- if:
- condition: numeric_state
entity_id: input_number.robot_aspirador_numero_de_limpiezas
below: 4
then:
- service: input_number.increment
target:
entity_id: input_number.robot_aspirador_numero_de_limpiezas
data: {}
else:
- service: notify.push_msg_javier
data:
title: Limpiar a Rogelia
message: El robot aspirador ya ha realizado 4 limpiezas y debe ser vaciado.
- service: notify.mail_javier
data:
title: Limpiar a Rogelia
message: El robot aspirador ya ha realizado 4 limpiezas y debe ser vaciado.
mode: single
icon: mdi:vacuum
To set it to 0, I have put a control panel in the menu where I can see the number of cleanings it has done and modify it.
if, for whatever reason, on the fourth cleaning I don’t clean and leave the counter at 0, it will continue to warn me after each cleaning.
I do something similar and use the counter to send the vacuum to the trash can and message me.
If you want to create a really luxurious version for a vacuum bin notification, then you could also create a datetime input helper or timestamp sensor when you last emptied the bin.
Once you have that then you can use that as the start time for a history sensor to see how long the vacuum has ran since then, and trigger when the runtime exceeds a certain duration:
In fact, I’m so happy with myself for thinking of this, I’ll go ahead and create something like it for myself. If I have time, I might even combine it with a task that I check when done, and create a new when when bin emptying is needed!
That does not seem like a script that you would have a need to run manually or with another automation. So, I would have put the actions in the automation instead of making a separate script to call.
But, I also would have marked the post that told you how to do it as the answer.
I did a full writeup, not only on how to see how long a vacuum has been used, but also how to integrate that with todo items and actionable notifications. Have fun!
you might consider using the MeasureIT integration from @daniel_d
it provides counters and stop-watches, that measure for defined times or unlimited until you reset it.
Extremely useful