#Advice on automation surviving restart

1 messages · Page 1 of 1 (latest)

bright field
#

Hi, I've read some things about timers surviving restarts and its hard to tell some of the things that I've read still apply or if they're outdated.

I have some zooz dimmers along with some motion sensors and if a user taps up or down on the paddles I want to disable turning on/off the lights due to motion for a set amount of time. I created an input boolean helper that is checked by the motion automations to determine if the light should be manipulated or not.

#

I have this other automation that manages the input toggle, as seen below:

alias: Dining Room Auto Lights Toggle
description: ""
triggers:
  - device_id: d7a6241696972ed86b82d693ff88b5a9
    domain: zwave_js
    type: event.value_notification.central_scene
    property: scene
    property_key: "001"
    endpoint: 0
    command_class: 91
    subtype: Endpoint 0 Scene 001
    trigger: device
    value: 0
    id: Dining Room Paddle Up
  - device_id: d7a6241696972ed86b82d693ff88b5a9
    domain: zwave_js
    type: event.value_notification.central_scene
    property: scene
    property_key: "002"
    endpoint: 0
    command_class: 91
    subtype: Endpoint 0 Scene 002
    trigger: device
    value: 0
    id: Dining Room Paddle Down
  - trigger: state
    entity_id:
      - input_boolean.Dining_room_auto_lights
    from:
      - "on"
    to:
      - "off"
    for:
      hours: 4
      minutes: 0
      seconds: 0
    id: Dining Room Auto Turned Off
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - Dining Room Paddle Up
              - Dining Room Paddle Down
        sequence:
          - action: input_boolean.turn_off
            metadata: {}
            target:
              entity_id: input_boolean.Dining_room_auto_lights
            data: {}
      - conditions:
          - condition: trigger
            id:
              - Dining Room Auto Turned Off
        sequence:
          - action: input_boolean.turn_on
            metadata: {}
            target:
              entity_id: input_boolean.Dining_room_auto_lights
            data: {}
mode: single

Since the Dining Room Auto Turned Off trigger uses a for timer does this run the risk of never running if HA restarts? If so, what would y'all recommend?

frozen copper
#

yes, for that trigger to work, home assistant has to be running continuously for 4 hours from the time when the state changed from on to off.

#

Using a persistent timer (check the "Restore state and time when Home Assistant starts" box) means that you can start the timer when the initial trigger happens, and then an automation can be triggered separately when the timer finishes, which can be after a HA restart.

#

you will also need to cancel the timer if someone turns the lights back on while the timer is running.

bright field
#

good point!

frozen copper
#

Note that triggering based on timers is actually a bit annoying right now. I recommend using a manual event trigger, the yaml for that looks like this: ```event_type: timer.finished
trigger: event
event_data:
entity_id: timer.your_timer_name

bright field
#

thank you, I really appreciate the help. This cuts through so many blog posts and all of their cruft

frozen copper
bright field
#

interesting, I'm running 2026.1.2, so that is probably available to me

frozen copper
#

yeah, but they haven't implemented any new triggers for timers yet. a few interesting ones are available for some other use cases tho.

bright field
#

Thanks for your help @frozen copper, I really appreciate it!

frozen copper
bright field
#

that's a small edge case that I'll probably be fine living with

#

it shouldn't happen 99% of the time

random garden
#

Another interesting way to for this is when the button is pressed . Set a date time helper to the time the lights should go back to normal. Then in the turn off automation use the fact the date time helper is in the future to determine the lights should stay on.