Automation climate off base in value template of entity

hi there!

thanks for your support for this case.
I have already this automation configured:

- id: '1618499813469'
  alias: '[Control] Temperature up to 22 C'
  description: Temperature up to  22 C
  trigger:
  - platform: numeric_state
    entity_id: sensor.sensor_temperatura_caseta_temperature
    value_template: '{{states.sensor.sensor_temperatura_caseta_temperature.state}}'
    above: '22'
  action:
  - service: switch.turn_off
    target:
      entity_id:
      - switch.sonoff_caseta_enchufe_fijo
      - switch.sonoff_caseta_enchufe_fijo_2
  mode: single

and temperature of that sensor is:

{{states.sensor.sensor_temperatura_caseta_temperature.state}} 25.3

but the automation is not working and climate is always on even with the temperature above of 22 as i have in this case :-/

any idea?

It will trigger only at the moment the temperature increases above 22. In other words, only when the temperature crosses the threshold value of 22. That’s how a Numeric State Trigger works.

Once the temperature is above 22, the automation will not be triggered. The temperature must first decrease below 22 and then increase above it to trigger the automation again.

If you don’t like that kind of trigger behavior, you should use a State Trigger with a Numeric State Condition that checks if the sensor’s temperature is above 22.

Thanks for your comments…!!
Do you have any example for use a State Trigger with a Numeric State Condition… I think it would be better to use that just thinking, for instance I have a power off and temperature go up or down and then I cannot control anymore till temperature crosses again the values configured.

Thanks

I overlooked to mention that your example also has an error. A Numeric State Trigger doesn’t support a value_template.

- id: '1618499813469'
  alias: '[Control] Temperature up to 22 C'
  description: Temperature up to  22 C
  trigger:
  - platform: state
    entity_id: sensor.sensor_temperatura_caseta_temperature
  condition:
  - condition: numeric_state
    entity_id: sensor.sensor_temperatura_caseta_temperature
    above: '22'
  action:
  - service: switch.turn_off
    target:
      entity_id:
      - switch.sonoff_caseta_enchufe_fijo
      - switch.sonoff_caseta_enchufe_fijo_2
  mode: single

If you wish, you can replace the Numeric State Condition with a Template Condition in shorthand notation:

- id: '1618499813469'
  alias: '[Control] Temperature up to 22 C'
  description: Temperature up to  22 C
  trigger:
  - platform: state
    entity_id: sensor.sensor_temperatura_caseta_temperature
  condition: "{{ trigger.to_state.state | int > 22 }}"
  action:
  - service: switch.turn_off
    target:
      entity_id:
      - switch.sonoff_caseta_enchufe_fijo
      - switch.sonoff_caseta_enchufe_fijo_2
  mode: single