Template value trigger: when current temperature is above xx?

Hi all, I just got my HA blue today, really excited about it!

I want to trigger an automation by temperature and set it up as follows

id: 'xxx'
alias: Test
description: ''
trigger:
  - platform: template
    value_template: '{{ states("sensor.mysa_c5fbd8_current_temperature")|float > 50.5 }}'
condition: []
action: []
mode: single

I have tested {{ states("sensor.mysa_c5fbd8_current_temperature")|float > 50.5 }} Result type: boolean and result is true; {{ states("sensor.mysa_c5fbd8_current_temperature")|float }} Result type: number and result is 65.5. However, this automation still won’t be triggered. Any helps would be appreciated!

It will only trigger when the state of the template changes from false to true. So if the temperature is already above 50.5 you have to wait for it to go below then back above.

Also you do not need a template for this.

trigger:
  - platform: numeric_state
    entity_id: sensor.mysa_c5fbd8_current_temperature
    above: 50.5
1 Like

Ohhh! That makes a lot of sense! Thank you so much for prompt response

You could set your automation to trigger on any change of temperature, then put the template in a condition:

trigger:
  - platform: state
    entity_id: sensor.mysa_c5fbd8_current_temperature
  condition:
  - condition: template
    value_template: '{{ trigger.to_state.state | float(0) > 50.5 }}'
1 Like