#Timed automations not working after HA restart

1 messages · Page 1 of 1 (latest)

kindred fog
#

This is very likely my fault, I've got an automation that turns an extractor fan on and off based on a temperature sensor. It seems like when I update/restart HA (just patched it to the latest) the timed section of the automation doesn't detect. The automation basically says if under/over X temp for Y minutes then turn on/off. However since the reboot it's been under the target temp for a few hours but the automation never fired. Including YAML below

alias: Extractor fan (off)
description: ""
triggers:
  - entity_id:
      - sensor.thermostat_networkcab_temperature
    below: 25
    for:
      hours: 0
      minutes: 10
      seconds: 0
    trigger: numeric_state
conditions:
  - condition: device
    type: is_on
    device_id: 6764600109f348e3f90d45a1b8fd4ba8
    entity_id: a49526fc4319140242daabff259f39fb
    domain: switch
actions:
  - type: turn_off
    device_id: 6764600109f348e3f90d45a1b8fd4ba8
    entity_id: a49526fc4319140242daabff259f39fb
    domain: switch
mode: restart

dawn steppe
#

Are you sure your sensor is actually reporting anything?

kindred fog
#

Yeah, it's only sending updates when the temp changes (battery zigbee device), the on-screen display is 24.8 (same as reporting in HA) so it won't send an update.

Even if the update wasn't happening, it's still below 25c for 3hrs. It's like post reboot the automation timers didn't start...

dawn steppe
#

Numeric state triggers only fire when you cross the threshold, so if it was below 25 when home assistant restarted, that makes sense

kindred fog
#

ah right, is there a better way to do this then? I'd rather it check every X seconds/minutes what the temp is a react that way, rather than waiting for an threshold event that could be missed. Don't want to melt my network kit 😄

dawn steppe
#

Could check it on home assistant start - there's a trigger for that

kindred fog
#

Excellent idea, ty!

#

I think this would be better then:

alias: Extractor fan (off)
description: ""
triggers:
  - trigger: time_pattern
    minutes: "10"
  - trigger: homeassistant
    event: start
conditions: []
actions:
  - choose:
      - conditions:
          - type: is_temperature
            condition: device
            device_id: acac719cd93072280f56df80859fa722
            entity_id: 44464c537270c8676b1d49b2fb06fd81
            domain: sensor
            below: 25
          - condition: device
            type: is_on
            device_id: 6764600109f348e3f90d45a1b8fd4ba8
            entity_id: a49526fc4319140242daabff259f39fb
            domain: switch
        sequence:
          - type: turn_on
            device_id: 6764600109f348e3f90d45a1b8fd4ba8
            entity_id: a49526fc4319140242daabff259f39fb
            domain: switch
      - conditions:
          - type: is_temperature
            condition: device
            device_id: acac719cd93072280f56df80859fa722
            entity_id: 44464c537270c8676b1d49b2fb06fd81
            domain: sensor
            above: 26
          - condition: device
            type: is_off
            device_id: 6764600109f348e3f90d45a1b8fd4ba8
            entity_id: a49526fc4319140242daabff259f39fb
            domain: switch
        sequence:
          - type: turn_on
            device_id: 6764600109f348e3f90d45a1b8fd4ba8
            entity_id: a49526fc4319140242daabff259f39fb
            domain: switch
mode: restart
#

Also in classic fashion, mixed up the on/off logic. This should be all good now. Many thanks!

#

Oh for anyone that finds this and didn't read the docs first /10 for the timer, not just 10 😄

warm basin
#

Using a time pattern is really a kludge, it’s kind of like asking yourself every 10 minutes if you’re hungry rather than just taking action when you get hungry.

Normally the answer is to add the restart trigger like hilburn suggested, and add the trigger(s) as conditions also. However, there is no for: option for numeric state conditions because that information is not available in the HA state machine. There is nothing HA can look at to determine if that condition is true.

So, you have to make that information available. To do that, create a template binary sensor that becomes true when the temp is below 25c. Then instead of a numeric state condition, you can use a state condition, and that does contain the for: option