Help with automation: trigger when temperature is below a level (not just dropping this level)

Hi, I need an automation which is triggered each time the temperature changed and then checked if the temperature is below some level. (Application is automatic window lifter, close the window when the room temperate in the room is too low)
I tried with numeric_state but this triggered only when it crossed the level. But unfortunately, in my case it could be that it is already below this level, hence it does not trigger.

I need a trigger that checked always the temperature when it drops, not just when it crossed the level. Any suggestion?
As mentioned, I used already numeric_state and Entity

triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.keller_hinten_1_temperatur
    below: 18
  - type: temperature
    device_id: 2781d829beda0b1cd971c985a1f2e687
    entity_id: d6939e2e7e0a3f3e714485b534737464
    domain: sensor
    trigger: device
    below: 18

Use a State trigger with a blank to value. This will cause the trigger to fire on every state change.

Then add a Numeric State condition to check that the value is below your threshold.

triggers:
  - alias: Fire on every Temperature change 
    trigger: state
    entity_id:
      - sensor.keller_hinten_1_temperatur
    to:
conditions:
  - condition: numeric_state
    entity_id:
      - sensor.keller_hinten_1_temperatur
    below: 18

You can add a Template condition if you also want to ignore rising temperatures.

  - condition: template
    value_template: "{{ trigger.to_state.state | float < trigger.from_state.state | float }}"

Depending on your use case, you may also want to take a look at the Generic Thermostat integration instead of using an automation.

2 Likes

Use a threshold sensor to track whether the temperature is below or above 18 deg (set lower limit to 18) and create an automation to close the window, if it is open, when the threshold sensor state changes from off to on

Thanks that works!

You fixed a long-lasting problem for me. Thanks!