Trying to get Home Assistant to send me a notification when temperature goes below a certain value

I have a Sonoff TH-10 with Tasmota installed that I am using to monitor the temperature of my aquarium via MQTT. I want Home Assistant to send an alert to my phone every time the temperature drops below 76.8. This is the automation I have setup:

TRIGGER
Trigger Type: Numeric State
Entity: sensor.basement_aquarium_temperature
Below: 76.8

ACTION
Action Type: Call Service
Service: notify.ios_andrews_iphone_xr
Service Data: { "data": { "push": { "badge": 5 } }, "message": "Check the basement aquarium temperature!", "title": "Basement Aquarium Temperature Alert" }

The same exact Action configuration send notifications for other triggers I have configured. So, I know that part works. I assume there’s an error with my trigger section, but I don’t know what I am doing wrong.

Can you post your code in a code block or pastebin it? We’ll need to see the exact formatting.

This should work for you:

trigger:
  - platform: template
    value_template: "{% if states.sensor.basement_aquarium_temperature.state | float > 76.8 %}true{% endif %}"
- id: basement_aquarium_temperature_alert_2
  alias: Basement Aquarium Temperature Alert 2
  trigger:
  - below: '76.8'
    entity_id: sensor.basement_aquarium_temperature
    platform: numeric_state
  condition: []
  action:
  - data:
      data:
        push:
          badge: 5
      message: Check the basement aquarium temperature!
      title: Basement Aquarium Temperature Alert
    service: notify.ios_andrews_iphone_xr

Thank you. I’ll give that a try. I still would like to know what I did wrong. I posted my code block in a separate reply.

One of two things, your sensors are returning stings instead of numeric number and your below trigger needs a numeric number. Two, I am not sure if the below trigger can handle a float, may only accept and int.

Looks good to me. Doesn’t matter if you have the quotes or not, it attempts to parse whatever you put in above or below as a number. It also accepts floats. Note that the automation won’t trigger unless the temperature actually goes from above that number to below. If it’s already below that number it won’t trigger.

If that’s not the issue, is the automation on and does the action work when you manually execute it?

I just tried to trigger it manually by clicking Execute and I did get a popup on my phone.

I did water change on my aquarium on Saturday, and forgot to turn the header back on. So, this morning I come downstairs and the temperature is 66 degrees in the tank and my phone has never alerted me to the temperature.

Is there a way to get the automation to trigger if the temperature is already below 76.8 when Home Assistant starts up?

You don’t need to assert true in those situations. Just put the test in {{}}

trigger:
  - platform: template
    value_template: "{{ states.sensor.basement_aquarium_temperature.state | float > 76.8 }}"

You could trigger auto every 5 minutes then condition on temperature. That will have a fixed frequency of checks, but it will also spam you every 5 minutes while temp is low.

Sure, change the trigger and condition blocks of your automation to something like this:

  trigger:
  - platform: homeassistant
    event: start
  - platform: numeric_state
    entity_id: sensor.basement_aquarium_temperature
    below: 76.8
  condition:
  - condition: numeric_state
    entity_id: sensor.basement_aquarium_temperature
    below: 76.8

It looks strange, but this will trigger when home assistant starts and the sensor is below that temperature OR when the sensor goes from above 76.8 to below 76.8.

Thanks @petro, I will note that.