I am absolutely new t Home Assistant and have been messing around the last couple of days trying to integrate my Xiaomi Roborock S6 MaxV. I finally succeeded: the vacuum can be controlled via Home Assistant.
Now I want to go one step further and automate the cleaning process.
Therefore I want the vacuum to start whenever everybods in the household has left the house.
Since tado knows when all people have left the house I figured it would be best to use tado as trigger.
Unfortunately this is where all my attempts fail. The system won’t even let me save my attempts.
This is the best I came up with.
platform: state
entity_id: sensor.arbeitszimmer_tado_mode
from: HOME
to: AWAY
action:
- service: vacuum.start
entity_id: vacuum.xiaomi_vacuum_cleaner
Can anyone give me a hint o how to proceed?
Would be very thankful.
Here’s what I suggest, create a History Stats sensor to record the amount of time your vacuum operates during the day (it automatically resets itself at midnight):
Now add a condition to your automation that checks if the History Stats sensor reports zero (in other words, the vacuum has not yet logged any operating time today).
alias: Start Vacuum
trigger:
- platform: state
entity_id: sensor.arbeitszimmer_tado_mode
from: home
to: away
condition: "{{ states('sensor.vacuuming_time_today') | int == 0 }}"
action:
- service: vacuum.start
entity_id: vacuum.xiaomi_vacuum_cleaner
I insertet the first code into the configuration.yaml
Then I tried to insert the condition into the existing automation.
Unfortunately I then am presented the following message:
Message malformed: Unexpected value for condition: ‘{{ states(‘sensor.vacuuming_time_today’) | int == 0 }}’. Expected numeric_state, state, sun, template, time, zone, and, or, not, device @ data[‘condition’][0]
By the way: would that also be possible:
condition: "{{ states('sensor.vacuuming_time_today') | int >= 60 }}"
alias: Start Vacuum
trigger:
- platform: state
entity_id: sensor.arbeitszimmer_tado_mode
from: home
to: away
condition:
- condition: template
value_template: "{{ states('sensor.vacuuming_time_today') | int == 0 }}"
action:
- service: vacuum.start
entity_id: vacuum.xiaomi_vacuum_cleaner
That condition requires the vacuum to have already operated for a certain amount of time ( > 60) before it will execute the action. You want to execute the action only if the vacuum has not operated yet (i.e. allow it to run only once a day).
Thank you very much again.
Now everything seems to work just fine.
I tried to edit your code to int <= 60.
Therefore the vacuum should only start if it hasn’t been running for one hour or longer, since cleaning the whole appartement takes it around 1,5 hours.
Please consider marking either my first or second post with the Solution tag (you can only mark one of them). It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has an accepted solution. Effectively, it indicates your issue is resolved and helps users find answers to similar questions.