Howto: Roborock to clean home 3 times a week, when no one's at home

Hey guys!

I’ve been using Home assistant for a while, but still not very good with creating automations.
I’d be happy if anyone could help me with the following.

Tool needs to job: Xiaomi Roborock S50

Tools I have, which can order the Roborock: Xiaomi Motion Detectors, Tracker configured on my router, which detects if my girlfriend or I’m away.

I’d like the roborock to clean the house monday, wednesday and friday, but only when both of us left the house. Don’t ask why I don’t use worktime hours simply! :slight_smile: (9:00 am - 5:00 pm)
There is one thing I need to be prepaired. If we leave the house several times a day, I don’t want the Robo to clean the house every time. So it can clean once a day maximum.

I’d be glad if any of you could help me, or show any templates. :slight_smile:
Cheers

1 Like

I am using an input boolean to prevent mutliple cleanups a day. You can take a look at my config here: https://github.com/TribuneX/home_assistant/blob/master/automation/robot.yaml

1 Like

this is how I do mine:

1 Like

thanks guys! gonna let you know which one worked for me. :slight_smile:

I don’t get it.
I’ve tried to create fake situations in the last two days, to see if it will run, and it didn’t.
tried to exclude the causes, and it is the ‘input_boolean.cleaned_today’.
if I mask those lines, in the condition part with #, the automation runs, but with this condition it doesn’t want to.
already tried to run the ‘Robot: Reset cleaned today counter’ automation manually, to create fake state for the input boolean, but still it’s like it still doesn’t have a state.

- alias: 'Robot: Reset cleaned today counter'
  initial_state: 'on'
  trigger:
    platform: time
    at: '17:52:00'
  action:
  - service: input_boolean.turn_off
    data:
      entity_id: input_boolean.cleaned_today




- alias: 'Robot: Robot cleanup if nobody is home'
  initial_state: 'on'
  trigger:
    platform: time
    at: '17:56:00'
  condition:
    condition: and
    conditions:
    - condition: time
      weekday:
      - mon
      - wed
      - fri
      - sat
    - condition: state
      entity_id: group.tracker
      state: home
#    - condition: state
#      entity_id: input_boolean.cleaned_today
#      state: 'off'
  action:
  - service: vacuum.turn_on
    entity_id: vacuum.xiaomi_vacuum_cleaner

any idea?

which version of HA are you on? Since 0.77.x you need start not turn_on anymore…
To test, simply run the automation manually…

it is 0.77, but as I said, the automation works.
I can start it manually, by triggering in front end, or do it automatically any time if I use hashtag to mask out the ‘input_boolean.cleaned_today’ condition.
it’s the boolean seems to be not working for me :confused:

Did you specify the input boolean in your config yaml?

input_boolean:   
  cleaned_today:
     name: 'Cleaned today'
     initial: off
     icon: mdi:broom

damn, didn’t know I had to. :slight_smile:
now it works, thanks buddy!

still have some trouble with this. :slight_smile:
are you sure, you’re using the Roborock S50?
I tried to dig out the ‘sensor.xiaomi_status’ you’re using, but there were no entity like this.
Tried to use ‘vacuum.xiaomi_vacuum_cleaner’ as the only entity I found, but it’s ‘Charging’ state didn’t work :confused:
So the vacuum just did it’s second round today. :smiley:

okay, made some research, and I found out, I need to specify this sensor as a template. :slight_smile:

  • platform: template
    sensors:
    vacuumbattery:
    value_template: “{{ states.vacuum.xiaomi_vacuum_cleaner.attributes.status }}”

It wil work now :slight_smile:

Actually you could simplify everything by not messing with any input booleans or sensors created just for single automation needs.

This should better suit your needs because cleaning will be started not matter when both of you leave home not only if you are away on ‘17:56:00’.

  trigger:
    - platform: state
      entity_id: group.tracker
      to: 'not_home'
      for:
        minutes: 3
  condition:  
    condition: and
    conditions:
      - condition: template
        value_template: '{{ now().weekday() in (1,3,5) }}'
      - condition: template
        value_template: '{{ now().day != states.automation.start_cleaning_when_everyone_is_away.attributes.last_triggered.day | default(0) }}'
  action:
    - service: vacuum.start
      entity_id: vacuum.xiaomi_vacuum_cleaner

Small adjustments may be needed. You may also consider using Workday Binary Sensor to handle workdays that are actually bank holidays in your country.

2 Likes

i also missed this. its not included in the main config, so didnt even think about it! :slight_smile: Thanks

tried this and worked great if nobody is home, when the set timer is, but what if want it to trigger as soon as last person leaves house?
i have set the group to include everyone, and just tried to leave out the

  trigger:
  - at: '12:00'
    platform: time
  - entity_id: group.anyone
    from: home
    platform: state
    to: not_home

and instead have a trigger when state goes from home to not_home… but it wont trigger…