Need help with Home Assistant alerts setup

Hi HA community,

I need your help, we’re going through a deep freeze low temperature in the north west and my boiler home heating pipe got frozen and burst. For next time I took some precautionary measures to help prevent frozen pipes. Another idea came to mind is use Home Assistant alerts to warn me if my Basement Boiler Room temperature sensor is below 60 degrees Fahrenheit and repeat every 30 minutes until temperature rises above 60 degrees Fahrenheit. This every 30 minutes warning notification will help me make sure I take action until problem is solved.

My sensor details:
Bsmt Boiler Room
My weather station Temp 4
entity: sensor.my_weather_station_temp_4

state_class: measurement
unit_of_measurement: °F
device_class: temperature
friendly_name: My weather station Temp 4

So I saw an example from Home Assistant Alert (Alert - Home Assistant)

template:
  - binary_sensor:
      - name: "Motion Battery is Low"
        state: "{{ state_attr('sensor.motion', 'battery') | float(default=0) < 15 }}"
        device_class: battery

alert:
  motion_battery:
    name: Motion Battery is Low
    entity_id: binary_sensor.motion_battery_is_low
    repeat: 30
    notifiers:
      - ryans_phone
      - kristens_phone

This example will begin firing as soon as the entity sensor.motion’s battery attribute falls below 15. It will continue to fire until the battery attribute raises above 15 or the alert is acknowledged on the frontend.

So I need to make a similar alert that will fire when Basement boiler room temperature drops below 60 degrees Fahrenheit and continue to fire every 30 minutes until temperature rises above 60.

I started with this:

template:
  My weather station Temp 2:
    name: Basement Boiler Room Temperature is too cold
    done_message: Basement Boiler Room temperature is now normal
    entity_id: sensor.my_weather_station_temp_2
    state: "{{ state_attr('sensor.my_weather_station_temp_2', 'measurement') | float(default=0) < 60 }}"
    repeat: 30
    can_acknowledge: true
    skip_first: true
    notifiers:
      - basement_and_1stfloor

Not sure I’m doing it right, any help appreciated

Are you sure that state_attr('sensor.my_weather_station_temp_4', 'measurement') is correct? Most temperature sensors will have the temperature as the state, not as an attribute called measurement.

template and alert are two seperate top-level headings… you can’t mash them together into one thing. If you already have template or alert headings in your configuration you will need to add the new entities under the existing headings.

template:
  - binary_sensor:
      - name: Boiler Room Temp Low
        state: >
          {{ state_attr('sensor.my_weather_station_temp_4', 'measurement') | float(0) < 60 }}"
        availability: >
          {{ state_attr('sensor.my_weather_station_temp_4', 'measurement') | float('no') is number }}"
 
alert:
  my_weather_station_temp_2:
    entity_id: binary_sensor.boiler_room_temp_low
    name: Basement Boiler Room Temperature is too cold
    done_message: Basement Boiler Room temperature is now normal
    repeat: 30
    can_acknowledge: true
    skip_first: true
    notifiers:
      - basement_and_1stfloor

It’s great to be notified but this is the kind of thing HA is made for. How about a small heater with a switch/plug when the temp is below desired temperature. An automation would turn on/off the heater as needed.

Thanks Didgeridrew, for quick response. Not sure if state_attr supposed to be measurement, wish there was a way to check through developer tools section or something. I took your advice and replaced ‘measurement’ with ‘state’. I’ll see what happens, as a test I turned off heat and see if I get an audio tts alert on my basement and 1st floor speakers.

Revised alert in /config/configuration.yaml looks like this:

Absolutely, that’s already in my to do list.

There is … the States tool will show the state as well as all the attributes of an entity.

Your updated template is not valid… to return the state you need to use states() not state_attr():

{{ states('sensor.my_weather_station_temp_4') | float(0) < 60 ) }}

1 Like

Yes I tried it in developer tools “states tool” section and it was helpful.
Modified it again (final code shown below) and test was successful!
Thanks again for your help. :slightly_smiling_face:

#Templates
template:
  - binary_sensor:
      - name: Boiler Room Temp Low
        state: "{{states('sensor.my_weather_station_temp_4') | float(0) < 60 }}"
        availability: "{{states('sensor.my_weather_station_temp_4') | float('no') is number }}"
# Alerts
alert:
  light_dimmer:
    name: Second floor fitness/office room light is on
    done_message: Second floor fitness/office room light is now off
    entity_id: light.fitness_office_room_2_dimmer_3
    state: "on"
    repeat: 5
    can_acknowledge: true
    skip_first: true
    notifiers:
      - basement_and_1stfloor
  my_weather_station_temp_4:
    entity_id: binary_sensor.boiler_room_temp_low
    name: Warning Basement Boiler Room temperature is below sixty degrees Fahrenheit home water pipes may freeze
    done_message: Basement Boiler Room temperature is now normal
    repeat: 30
    can_acknowledge: true
    skip_first: true
    notifiers:
      - basement_and_1stfloor
      - 2nd_floor