Climate Template!

Hi everyone!

I wanted to create an automation that would allow me to receive a notification on my phone when the temperature of the CPU of my raspberry had exceeded a certain temperature (for example 45°C).

I wrote this template and used it as an automation trigger. However it doesn’t trigger!!!

The automation is the following one:

- id: '1623724337543'
  alias: Automazione Alert CPU
  description: ''
  trigger:
  - platform: template
    value_template: "{% if states('sensor.cputemp') != '40' %}\n  True\n{% else %}\n\
      \  false\n{% endif %}"
  condition: []
  action:
  - service: notify.mobile_app_pixel_4_xl
    data:
      title: Home Assistant
      message: '!!!ALERT!!! La temperatura della CPU ha raggiunto e/o superato i 55°C'
  mode: single

Anyone can help me???

No need for templates.

- id: '1623724337543'
  alias: Automazione Alert CPU
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.cputemp
    above: 45
  condition: []
  action:
  - service: notify.mobile_app_pixel_4_xl
    data:
      title: Home Assistant
      message: '!!!ALERT!!! La temperatura della CPU ha raggiunto e/o superato i 45°C'
  mode: single

No! I tried that! It won’t trigger either!
I searched on the web and I found that is possible that some sensors give “not numeric” values… So the solution was to create a template from these sensors to fire the automation…

But it does not work either

That does work, but the temperature has to cross from below 45 to above. So if it is already above 45 it won’t trigger.

All sensor states are strings. The numeric_state trigger still works.

1 Like

But what if I do a server restart? Doesn’t it work either? Does it necessarily have to exceed the temperature value to perform the automation?
I thought that after a server restar, If it had found a value greater than 45, it would have started the automation

No it wont. But you could add another trigger and a condition to do that. You can also get the current temperature in your message:

- id: '1623724337543'
  alias: Automazione Alert CPU
  description: ''
  trigger:
  - platform: numeric_state
    entity_id: sensor.cputemp
    above: 45
  - platform: homeassistant
    event: start
  condition:
    condition: numeric_state
    entity_id: sensor.cputemp
    above: 45
  action:
  - service: notify.mobile_app_pixel_4_xl
    data:
      title: Home Assistant
      message: '!!!ALERT!!! The current CPU temperature is {{ trigger.to_state.state}} °C'
  mode: single
1 Like

It worked! Thank you very much!!! You’re my savior!

1 Like