Do conditions/triggers for a certain period of time carry over a server restart?

let me explain what i mean…i have the following automation that disallows setting the thermostat below a certain threshold when it’s during peak electricity cost hours:

- alias: "Downstairs Thermostat Peak Time Temperature Adjust"
  trigger:
    platform: state
    entity_id: sensor.downstairs_ac_below_78
    to: 'True'
    for:
      minutes: 30
  condition:
    condition: and
    conditions:
      - condition: time
        after: '14:00:00'
      - condition: time
        before: '20:00:00'
      - condition: time
        weekday:
          - mon
          - tue
          - wed
          - thu
          - fri
  action:
    - service: climate.set_temperature
      entity_id: climate.downstairs
      data:
        temperature: 78

this works exactly as i want it to work…the only issue is that if i’m making changes and i happen to reload hass while this condition is in effect (i.e. while it’s set below 78 between 2pm and 8pm), the automation doesn’t trigger. i’m assuming this is because i restarted the server and thereby killed the trigger mechanism (i.e. when the server came back up, the thermostat was already set below 78 so it didn’t trigger the automation).

is there a way to get this type of trigger mechanism to carry across a server restart?

I would use fact that the state of a switch is stored for restart. For your use, I would create a dummy switch (or input select if its state is stored on restart) that you turn on first thing in the action in the automation and shut off as the last action. I would then add a trigger to check if that dummy switch is on which would happen if the automation action hadn’t got a change to finish like on restart.

edit: On another look, I think the problem is the trigger doesn’t know if its been 30 mins on restart because it didn’t turn to True yet which starts the clock.

I use a concept to lock a door which i think might work. The idea is to use time as the trigger and put your trigger as a condition. I think if you automate HA to run the following script every min, it should work.

turn_heat_on
  sequence:
  - condition:
      condition: and
      conditions:
        - condition: state
          entity_id: sensor.downstairs_ac_below_78
          state:  'True'
          for:
            minutes: 30 
        - condition: time
          after: '14:00:00'
        - condition: time
          before: '20:00:00'
        - condition: time
          weekday:
            - mon
            - tue
            - wed
            - thu
            - fri
    action:
      - service: climate.set_temperature
        entity_id: climate.downstairs
        data:
          temperature: 78

right, i figured this was the problem…when the server restarts, it’s already true so the trigger mechanism isn’t firing to start the 30 minute clock. i’m trying to avoid running too many minute or 5 minute or 10 minute (/ whatever) time based triggers…

I agree, time based triggers add a lot of entries in the logs. Another idea is the run the above script over and over with another script so you only need to trigger once on restart. you will need another script as the condition in the above script will kill the process if not met. Another script like this

  temp_script:
    sequence:
      - delay:
          minutes: 1
      - service: script.turn_on
        entity_id: script.turn_heat_on
      - service: script.turn_on
        entity_id: script.temp_script