Trigger vacuume if away but only once

Hi all,

I have an automation setup to vacuum daily at 10 am and to skip rooms that have a specific person at home (i.e. if I am at home, it will skip my office for vacuum. If my wife is at home, it will skip her office for vacuuming, etc). This works great.

I want to add another option to vacuum the whole house when we are all away but only once as there is no point continually doing this every day (e.g. if we go on holiday or away for multiple days).

Any ideas how I could do this?

Here is my current code -

alias: Vacuum - Regular cleaning weekday
description: ""
trigger:
  - platform: time
    at: "10:00:00"
condition:
  - condition: state
    entity_id: vacuum.dreamebot_d10_plus
    state: docked
  - condition: time
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  - condition: state
    entity_id: input_boolean.guest_mode
    state: "off"
action:
  - choose:
      - conditions:
          - condition: state
            entity_id: person.rory_lawson
            state: home
          - condition: state
            entity_id: person.nicola
            state: not_home
        sequence:
          - service: dreame_vacuum.vacuum_clean_segment
            data:
              segments:
                - 6
                - 10
                - 9
                - 5
                - 4
                - 3
                - 1
            target:
              entity_id: vacuum.dreamebot_d10_plus
      - conditions:
          - condition: state
            entity_id: person.rory_lawson
            state: not_home
          - condition: state
            entity_id: person.nicola
            state: home
        sequence:
          - service: dreame_vacuum.vacuum_clean_segment
            data:
              segments:
                - 6
                - 10
                - 9
                - 5
                - 2
                - 3
                - 1
            target:
              entity_id: vacuum.dreamebot_d10_plus
      - conditions:
          - condition: state
            entity_id: person.rory_lawson
            state: home
          - condition: state
            entity_id: person.nicola
            state: home
        sequence:
          - service: dreame_vacuum.vacuum_clean_segment
            data:
              segments:
                - 6
                - 10
                - 9
                - 5
                - 3
                - 1
            target:
              entity_id: vacuum.dreamebot_d10_plus
mode: single

Don’t know about the dreamebot_d10_plus integration, but I’m using a helper to achieve similar. Here is the full automation for both Vacuum Cleaners, including ‘some more’ like vacuuming at specific moments, night, and on coming home based on proximity:

alias: "Vacuum: Robot Vacuums"
description: ""
trigger:
  - platform: zone
    entity_id: person.samuel81
    zone: zone.work
    event: enter
    id: vacuum_samuel81arrivedwork
  - platform: zone
    entity_id: person.samuel81
    zone: zone.church
    event: enter
    id: vacuum_samuel81atchurch
  - platform: state
    entity_id:
      - sensor.upstairs_robot_vacuum_status
    to: "5"
    id: upstairs_vacuum_completed
    for:
      hours: 0
      minutes: 0
      seconds: 2
    from: "6"
  - platform: state
    entity_id:
      - sensor.upstairs_robot_vacuum_status
    to: "2"
    id: upstairs_vacuum_started
    for:
      hours: 0
      minutes: 0
      seconds: 2
    from: "5"
  - platform: state
    entity_id:
      - sensor.upstairs_robot_vacuum_status
    to: "6"
    id: upstairs_vacuum_returning
    for:
      hours: 0
      minutes: 0
      seconds: 2
  - platform: time
    at: "10:00:00"
    id: vacuum_homeoffice
  - platform: state
    entity_id:
      - sensor.upstairs_robot_vacuum_status
    id: upstairs_vacuum_error
    for:
      hours: 0
      minutes: 0
      seconds: 2
    to: "4"
    from: "2"
  - platform: tag
    tag_id: 57d2d42b-997c-437c-8b60-676733c1a964
    id: upstairs_vacuum_dustbinemptied
  - platform: numeric_state
    entity_id: sensor.proximity_home_samuel81_template
    above: "25"
    id: vacuum_awaysaturday
  - platform: state
    entity_id:
      - vacuum.roomba
    from: cleaning
    to: returning
    id: downstairs_vacuum_returning
  - platform: state
    entity_id:
      - vacuum.roomba
    from: docked
    to: cleaning
    id: downstairs_vacuum_started
  - platform: state
    entity_id:
      - vacuum.roomba
    from: cleaning
    to: returning
    id: downstairs_vacuum_completed
  - platform: state
    entity_id:
      - input_boolean.upstairs_is_vacuumed_today
    from: "off"
    to: "on"
    id: Upstairs Vacuumed Dustbin Counter Plus
  - platform: numeric_state
    entity_id: zone.home
    for:
      hours: 0
      minutes: 15
      seconds: 0
    below: 1
    id: Cleaning when dog has left
  - platform: state
    entity_id:
      - vacuum.roomba
    attribute: status
    from: Running
    id: Running to Docked
    to: End Mission
  - platform: state
    entity_id:
      - input_boolean.clean_the_house_when_i_m_gone
    from: "off"
    to: "on"
    id: Override Cleaned Floors
  - platform: state
    entity_id:
      - vacuum.roomba
    from: returning
    to: docked
    id: Vacuum Lights Off Downstairs
  - platform: state
    entity_id:
      - vacuum.roomba
    from: paused
    to: cleaning
    id: Vacuum Lights On Downstairs
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: vacuum_samuel81arrivedwork
          - condition: state
            entity_id: input_boolean.guests_in_the_house
            state: "off"
          - condition: state
            entity_id: binary_sensor.officeday_samuel81
            state: "on"
          - condition: numeric_state
            entity_id: zone.home
            below: 1
          - condition: state
            entity_id: input_boolean.dog_stays_home
            state: "off"
        sequence:
          - service: script.turn_on
            data: {}
            target:
              entity_id: script.vacuum_start
      - conditions:
          - condition: trigger
            id: vacuum_samuel81atchurch
          - condition: state
            entity_id: input_boolean.guests_in_the_house
            state: "off"
          - condition: state
            entity_id: binary_sensor.night
            state: "off"
          - condition: numeric_state
            entity_id: zone.home
            below: 1
          - condition: state
            entity_id: input_boolean.dog_stays_home
            state: "off"
        sequence:
          - service: script.turn_on
            data: {}
            target:
              entity_id: script.vacuum_start
      - conditions:
          - condition: trigger
            id: upstairs_vacuum_started
        sequence:
          - service: notify.notification_devices_household_primary
            data:
              title: Household Notification
              message: Heidi has just started cleaning
            enabled: false
      - conditions:
          - condition: trigger
            id: upstairs_vacuum_completed
        sequence:
          - service: notify.notification_devices_household_primary
            data:
              title: Household Notification
              message: Heidi has just finished cleaning
            enabled: false
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id:
                - input_boolean.upstairs_is_vacuumed_today
      - conditions:
          - condition: trigger
            id: downstairs_vacuum_started
        sequence:
          - service: notify.notification_devices_household_primary
            data:
              title: Household Notification
              message: George has just started cleaning
            enabled: false
      - conditions:
          - condition: trigger
            id: downstairs_vacuum_completed
        sequence:
          - service: notify.notification_devices_household_primary
            data:
              title: Household Notification
              message: George has just finished cleaning
            enabled: false
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id:
                - input_boolean.downstairs_is_vacuumed_today
      - conditions:
          - condition: trigger
            id: downstairs_vacuum_returning
        sequence: []
      - conditions:
          - condition: trigger
            id: upstairs_vacuum_returning
        sequence: []
      - conditions:
          - condition: trigger
            id: vacuum_homeoffice
          - condition: state
            entity_id: input_boolean.today_is_homeoffice
            state: "on"
          - condition: state
            entity_id: input_boolean.guests_in_the_house
            state: "off"
          - condition: numeric_state
            entity_id: zone.home
            below: 2
          - condition: state
            entity_id: input_boolean.dog_stays_home
            state: "off"
        sequence:
          - service: script.turn_on
            data: {}
            target:
              entity_id: script.vacuum_start
      - conditions:
          - condition: trigger
            id: upstairs_vacuum_error
        sequence:
          - service: notify.notification_devices_household_primary
            data:
              title: Heidi can't breathe!
              message: >-
                The upstairs robot vacuum ran into an error. Would you like to
                retry operations?
              data:
                actions:
                  - action: RETRY_VACUUM
                    title: "Yes"
                  - action: DISMISS
                    title: No, thanks
          - wait_for_trigger:
              - platform: event
                event_type: mobile_app_notification_action
                event_data:
                  action: RETRY_VACUUM
            timeout: "00:30:00"
            continue_on_timeout: false
          - service: vacuum.start
            data: {}
            target:
              entity_id: vacuum.mijia_v2_17b9_robot_cleaner
          - service: notify.notification_devices_household_primary
            data:
              message: The robot vacuum has been restarted.
          - service: vacuum.set_fan_speed
            data:
              fan_speed: Enchance
            target:
              entity_id: vacuum.mijia_v2_17b9_robot_cleaner
      - conditions:
          - condition: trigger
            id: upstairs_vacuum_dustbinemptied
        sequence:
          - service: input_datetime.set_datetime
            data_template:
              date: "{{ now().strftime(\"%G-%m-%d\") }}"
            target:
              entity_id: input_datetime.upstairs_robot_vacuum_dust_bin_last_emptied
          - service: counter.reset
            data: {}
            target:
              entity_id: counter.upstairs_robot_vacuum_dust_bin_last_last_emptied
      - conditions:
          - condition: trigger
            id: vacuum_awaysaturday
          - condition: state
            entity_id: input_boolean.guests_in_the_house
            state: "off"
          - condition: state
            entity_id: proximity.home_samuel81
            attribute: dir_of_travel
            state: away_from
          - condition: time
            weekday:
              - sat
              - fri
          - condition: state
            entity_id: binary_sensor.workday_samuel81
            state: "off"
          - condition: state
            entity_id: input_boolean.house_in_vacation_mode
            state: "off"
          - condition: numeric_state
            entity_id: zone.home
            below: 1
          - condition: state
            entity_id: input_boolean.dog_stays_home
            state: "off"
        sequence:
          - service: script.turn_on
            data: {}
            target:
              entity_id: script.vacuum_start
      - conditions:
          - condition: trigger
            id: Upstairs Vacuumed Dustbin Counter Plus
        sequence:
          - service: counter.increment
            data: {}
            target:
              entity_id: counter.upstairs_robot_vacuum_dust_bin_last_last_emptied
      - conditions:
          - condition: trigger
            id:
              - Clean the house when I'm gone
          - condition: state
            entity_id: input_boolean.clean_the_house_when_i_m_gone
            state: "on"
          - condition: state
            entity_id: input_boolean.dog_stays_home
            state: "off"
        sequence:
          - service: script.turn_on
            data: {}
            target:
              entity_id: script.vacuum_start
      - conditions:
          - condition: trigger
            id:
              - Running to Docked
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.clean_the_house_when_i_m_gone
      - conditions:
          - condition: trigger
            id:
              - Override Cleaned Floors
          - condition: state
            entity_id: input_boolean.dog_stays_home
            state: "off"
        sequence:
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id:
                - input_boolean.upstairs_is_vacuumed_today
                - input_boolean.downstairs_is_vacuumed_today
      - conditions:
          - condition: trigger
            id:
              - Cleaning when dog has left
          - condition: state
            entity_id: input_boolean.clean_the_house_when_i_m_gone
            state: "off"
          - condition: and
            conditions:
              - condition: numeric_state
                entity_id: sensor.christa_presence_yesterday
                above: 0
              - condition: numeric_state
                entity_id: sensor.chista_presence_today
                below: 1
          - condition: state
            entity_id: input_boolean.dog_stays_home
            state: "off"
        sequence:
          - service: script.turn_on
            data: {}
            target:
              entity_id: script.vacuum_start
      - conditions:
          - condition: trigger
            id:
              - Vacuum Lights On Downstairs
          - condition: state
            entity_id: binary_sensor.above_3_0
            state: "off"
          - condition: state
            entity_id: input_boolean.goodnight_activated
            state: "on"
        sequence:
          - service: light.turn_on
            data:
              brightness_pct: 1
            target:
              entity_id:
                - light.livingroom_vintage_lamp_on_the_dressoir
                - light.diningroom_table_light
                - light.kitchen_led_strip
                - light.livingroom_pine_lamp
                - light.kitchen_fan_left
                - light.kitchen_fan_right
                - light.diningroom_bookcase_light
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.vacuum_lights_downstairs
      - conditions:
          - condition: trigger
            id:
              - Vacuum Lights Off Downstairs
          - condition: state
            entity_id: input_boolean.vacuum_lights_downstairs
            state: "on"
          - condition: state
            entity_id: input_boolean.house_in_night_mode
            state: "on"
            enabled: false
          - condition: state
            entity_id: binary_sensor.above_3_0
            state: "off"
        sequence:
          - service: light.turn_off
            target:
              entity_id:
                - light.livingroom_vintage_lamp_on_the_dressoir
                - light.diningroom_table_light
                - light.kitchen_led_strip
                - light.livingroom_pine_lamp
                - light.kitchen_fan_left
                - light.kitchen_fan_right
                - light.diningroom_bookcase_light
            data: {}
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.vacuum_lights_downstairs
    default: []
mode: parallel
max: 25

You could create an input helper toggle called “house_is_clean” and as part of your existing automation you can turn the toggle on when it runs the new choose block when nobody is home. You can then create another automation to turn the toggle off when either person changes from not_home to home.

Unrelated, but be aware that the state “not_home” actually means “not in any defined zone”. If you define a zone called “work” for example, your automation would not work as expected when you are at work. What you should do is use a “not” condition, and then use the state condition for being home.

3 Likes