Stop automation if another has already run that day

Hi

I seem to be getting confused with the automation conditions. I have a scripts setup that get called 2 hours before me or the girlfriend have work. I still tend to get up with her when i’m on a later start so i don’t need mine to run. How do i set the condition so it doesn’t trigger for that day?

- alias: 'time to get up gruff'
  trigger:
    platform: state
    entity_id: sensor.my_event_offset
    to: 'on'
  condition:
    condition: state
    entity_id: person.gruffdris
    state: 'home'
  action:
    service: script.turn_on
    entity_id: script.im_awake

- alias: 'time to get up rhiddz'
  trigger:
    platform: state
    entity_id: sensor.rhiddz_event_offset
    to: 'on'
  condition:
    condition: state
    entity_id: person.rhiddz
    state: 'home'
  action:
    service: script.turn_on
    entity_id: script.rhiddz_awake

Simply turn the ‘other’ automation off in your scripts and at a given time turn them on for the next morning.

Cheers

Added a service to stop it and a delay to tun it back on :slight_smile:

    - service: automation.turn_off
      data:
        entity: automation.time_to_get_up_gruff
    - delay: 
        hours: 6
    - service: automation.turn_on
      data:
        entity: automation.time_to_get_up_gruff
1 Like

I would not use a delay for 6 hours as a reboot will cause this to fail. Just check and enable the automations at midnight if needed.

1 Like

What about a simple template conditoin for the one automation “Name 1” which should run if the automation “Name 2” has not run within the last 3600 seconds

- alias: "Name 1"
  trigger:
    ...
  condition:
    - condition: template
      value_template: '{{as_timestamp(now()) - as_timestamp(states.automation.name_2.attributes.last_triggered)|
            int >= 3600}}'
  action:
    ...

Is that helping?

Regards
Ralf

3 Likes