Automation shall not be interrupted by reboot

I have a long running automation to turn of my heater when the indoor temperature is above a value for 2 days. Unfortunately this does not work, when home assistant is restarted during this time. How can I solve this?

Here my automation:

alias: Heizung ausschalten
description: ""
  - platform: numeric_state
      - sensor.wohnzimmer_temperature
      hours: 48
      minutes: 0
      seconds: 0
    above: 21.7
condition: []
  - service: switch.turn_off
    data: {}
      entity_id: switch.luxtronik2_heating
mode: single

use a timer.

set it any time sensor first triggers above 21.7 and kill it any time it falls below 21.7

in your config yaml configure the timer to restore: true which will make it restore after a reboot.

1 Like

I was looking for something similar a little while ago and set it up as recommended here - take a look, it might help:

Long Term Duration for Numeric State Trigger (7+ days) - Configuration - Home Assistant Community (

If you use arnedad’s suggestion, keep in mind that when a timer is restored after a restart, its new duration is reduced by the amount of time Home Assistant took to restart. For example, if there’s a power failure and Home Assistant is inoperative for an hour, when it restarts the timer’s new duration will be reduced by 1 hour. In other words, the amount of downtime is deducted from the timer’s countdown when it’s restored on startup.

I will normally go the timer route too, because I’d like to see the remaining time, but in this case I’m not sure it is even useful.

This, another option is to set an input_datetime helper in your automation with this future time when conditions are met, and then make a second automation with a time trigger that will trigger at the time of the input_datetime (use it in the at: of a time trigger). In the first automation you remove the for: and only have an action to set the helper. In the second automation, you turn off the heating.