Automation based on temperature never triggers

Hi, I have this automation that turns the heating on for 30 minutes if the average temperature of the house is less than 20 for longer than 5 minutes. I recall this one working some time ago. I’m not sure I’ve edited something or not but now it never triggers. Any idea on why it might be?
I expect it to run again at the end if the trigger is valid again (i.e. if after running the avg temp is still below 20 then run again). Am I thinking wrong?
Thanks

alias: Heating
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.temp_house_avg
    for:
      hours: 0
      minutes: 5
      seconds: 0
    below: 20
    value_template: |+

conditions: []
actions:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.heater_tasmota
  - delay:
      hours: 0
      minutes: 30
      seconds: 0
      milliseconds: 0
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.heater_tasmota
mode: single

triggers only fire when the value crosses the threshold, which I personally had some confusion about.

your code above will only fire when it the temp drops below 20, not when it already is below 20.

it fires once, then it will not fire again until it goes above 20 and back below 20.

1 Like

oooh…ok that was confusing…so how I guess I should detect every temperature change and the verify with a condition if it’s below 20 right? But how would I detect every change? I don’t think there’s a state for that entity. thanks

I would remove the 30 minute delay and add a second trigger that turns off the heater when the temperature goes above a certain value. E.g. above 21 or whatever you choose

1 Like

Use a template trigger

  trigger:
    - platform: template
      value_template: "{{ states('sensor.temp_house_avg') | int(99) < 20 }}"
      for: "00:05:00"
      id: ave_low

Hi. can you explain what’s the difference and why this one would work? thanks

Why not just use a generic thermostat?

Also I’m not sure this is valid

1 Like

I tried implementing generic thermostat but didn’t fix my previous issue.

alias: Caldaia_heath
description: ""
triggers:
  - trigger: numeric_state
    entity_id:
      - climate.caldaia
    for:
      hours: 0
      minutes: 5
      seconds: 0
    attribute: current_temperature
    below: 20
conditions: []
actions:
  - action: climate.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: climate.caldaia
  - delay:
      hours: 0
      minutes: 30
      seconds: 0
      milliseconds: 0
  - action: climate.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: climate.caldaia
mode: single

The docs describe the trigger behaviors very well.

Ok…
So now the question becomes, why do you have an automation when you have a generic thermostat.
The whole point of a thermostat is to do stuff without an automation.
If you set up the thermostat then it could just be turned on and forgotten about.
It should not need an automation unless you want some kind of presence detection.
Just heat control is what it’s built for and does not need an automation