Trying to Fire Alert if Temp Sensor is out of a certain range

I have a few temperature sensors that monitor our coolers. They need to be in a specific range.
In my configuration.yaml I added the following

homeassistant:
  customize:
    sensor.south_cooler_temperature:
      upper: 21
      lower: 6

My understanding is that if that sensor returns a value outside of the upper or lower range it will then fire an alert that I have configured in configurations.yaml like so:

alias: Temp out of range
variables:
  t_max: "{{ state_attr(trigger.entity_id, 'upper') }}"
  t_min: "{{ state_attr(trigger.entity_id, 'lower') }}"
  val: "{{ trigger.to_state.state | float(0) }}"
trigger:
  - platform: state
    entity_id:
      - sensor.south_cooler_temperature
condition:
  - condition: template
    value_template: "{{ not t_min < val < t_max }}"
action:
  - service: notify.gmailsmtp
    data:
      title: Temp out of Range
      message: Check the Temperature Sensors ASAP

Nothing seems to be firing at all. I know that my service notify.gmailsmtp works because I test it in the service gui and it sends and email fine.

I’ve been banging my head now for a couple days on this… help please :slight_smile:

What do the traces show?

Though it’s not one I would normally use, your trigger/variable/condition structure is working on my instance.

Why not just do this in an automation, at least that way you can easily trace what happens every time it fires (or if it fires at all)?

I actually did get it to fire again. I did some more searching and noticed that my filter state was set to off


Switched it to on and it has been firing this afternoon.

Thank you

Could you point me in the right direction for this? What I’d really like to do is to have events fire for multple temperature sensors. I tried to go under settings, then Automations and Scenes, but I get an error 500 when I try and save.

I don’t know why you are getting error 500, it will generally tell you if your automation is invalid. You need a trigger, optional condition and action(s).

Your trigger would be when your sensor device changed value of any kind. The condition could be only if the value changed above or below a certain value. The action would be to send you the notification via Call Service and Notification.