Delay action to specific time

Hey there,

I’m technically not new to programming I am very new to home assistant and never done much in yaml. I would like to have an automation that checks if everyone left home the vakuum starts. Thats easy enough and I do have it running. However, it can happen, that my boyfriend and I would leave the house before 6 o’clock. Is there any way that I can tell home assistant to delay the action until at least 6 o’clock (or even later) so I do not wake up my neigbors.

I have not jet added the vakuum to home assistant so currently it only turns on a light :smiley:

alias: RoombarAutomation_EveryoneLeftHome
trigger:
  - platform: state
    entity_id:
      - zone.home
    to: "0"
    attribute: persons
condition:
  - below: "1"
    condition: numeric_state
    entity_id: counter.roombaautomation_everyonelefthome_triggercounter
action:
  - service: counter.increment
    target:
      entity_id:
        - counter.roombaautomation_everyonelefthome_triggercounter
    data: {}
  - type: turn_on
    device_id: 7ba208d813f593f677f4e2de2302f36b
    entity_id: light.signify_netherlands_b_v_lct012_huelight
    domain: light

What is the counter’s purpose?

I dont wont the automation to start everytime we leave the house. Just once and it is fine to do so if we leafe the house the first time. There are days we leafe the house multiple times… I do not need my flat to be vakuumed that much xD

I dont wont the automation to start everytime we leave the house. Just once and it is fine to do so if we leafe the house the first time. There are days we leafe the house multiple times… I do not need my flat to be vakuumed that much xD

Sorry didn’t reply directly the first time…

This automation is designed to execute no more than once a day.

It triggers at 7:00 and when everyone has left home. Then it checks if:

  • If it has not yet executed today.
  • The vacuum is not already on.
  • No one is home.
  • It’s later than 06:00.

If all conditions are true, it proceeds to turn on the vacuum.

alias: RoombarAutomation_EveryoneLeftHome
trigger:
  - platform: state
    entity_id:
      - zone.home
    to: "0"
    attribute: persons
  - platform: time
    at: '07:00:00'
condition:
  - "{{ this.attributes.last_triggered < today_at() }}"
  - "{{ states('vacuum.roomba') != 'on' }}"
  - "{{ now().hour > 6 }}"
  - condition: state
    entity_id:
      - zone.home
    state: "0"
    attribute: persons
action:
  - service: vacuum.turn_on
    target:
      entity_id: vacuum.roomba
1 Like

Stupid question… would it also trigger if we for what ever reason leafe the house after 7?

If everyone leaves later than 07:00, it will trigger and check its conditions.

  1. Has the automation not executed its actions today?
  2. Is the vacuum not running?
  3. Is it later than 06:00?
  4. Is nobody home?

If the answer is Yes to all questions then the automation will turn on the vacuum.

Thank you very much :smiley:

1 Like

You’re welcome!