Trying to get a simple notification based on temperature

Hi everyone!

I just started playing with HA and I am trying to get a notification sent to a mobile device when a temperature sensor get over a certain temperature. My automation is based mostly on this post:

Here is what it looks like in my automation.yaml file:

  alias: Notify over 11C
  description: ''
  trigger:
  - platform: template
    value_template: '"{{ states.sensor.netatmo_home_outdoor_temperature.state | float
      > 11 }}"'
  condition: []
  action:
  - data:
      message: Notification works!
      title: Temp over 11C
    service: notify.mobile_app_pnote10

I’ve executed the automation manually and I received the notification which means this part works. I also tested the template statement in the template editor to see if the statement was working using different values and it returns true or false as it should depending on the tested value vs the reported temperature of the sensor.

But, I am not getting any notification whenever the temperature gets over 11C. I guess I am missing something but so far I couldn’t find what in the forums.

Any idea?

It’probably related to your wrong use of quotes.
Also try to avoid the states.xxx.sss notationand use states(‘xxx.sss’) instead as described here. Try this:

platform: template

value_template: "{{ states('sensor.netatmo_home_outdoor_temperature') | float > 11 }}"

Thanks for the reply but it still doesn’t work. I tried modifying my automation as per your suggestion (see below) but I still didn’t receive any notification when the temperature sensor passed the value. Also, just to be sure, I restarted HA after making the modification just to make sure that it would reload the new automation.

  alias: Notify over 11C
  description: ''
  trigger:
  - platform: template
    value_template: '"{{ states(''sensor.netatmo_home_outdoor_temperature'') | float
      > 13.2 }}"'
  condition: []
  action:
  - data:
      message: Notification works!
      title: Temp over 11C
    service: notify.mobile_app_pnote10

At least, it is getting warmer outside! :stuck_out_tongue:

Ok, just realized after pasting my code here that my modification actually added some kind of double quote. This might be the problem.

So did you fix it? My code should work, just copy it 1:1

Yes, I just tested it and it works. I realized that my error probably came from the fact that I used the automation editor in the GUI which seems to add those double quote when saving. It worked when I edited the yaml file directly.

Thanks again!

1 Like