I have 3 temperature sensors in freezers that I want to monitor in case something goes wrong. I’d like to check them once an hour and if any one of the sensors is warmer than -10C or unavailable then I want an email alert telling me which one(s) caused the alert.
I’ve found a few examples but they are a few years old and don’t seem to work for me…
Hopefully someone could help me out?
alias: Email Freezer Temps YAML
description: ""
trigger:
- platform: time_pattern
minutes: "00"
condition:
- condition: numeric_state
entity_id: sensor.ibs_th2_p01b_09a6_temperature
above: -10
- condition: numeric_state
entity_id: sensor.ibs_th2_p01b_06c1_temperature
above: -10
- condition: numeric_state
entity_id: sensor.ibs_th2_p01b_15b8_temperature
above: -10
action:
- service: notify.o365_email_o365tommy
metadata: {}
data:
message: Freezer Test
data: >-
The {{ trigger.to_state.name }} is too warm or not available.
mode: single
But I don’t actually think that is really what you want… because the rest of the automation doesn’t make sense.
Even after fixing the extra 0, the automation:
Will run at the top of every hour…
If, and only if, all three sensors are above -10…
Then, it won’t do anything because there is an internally invalid template string as a value for a configuration key that requires a dictionary. O365 custom integration docs.
Why? If you forget to shut the door at 12:01, you’ll have an hour of defrosting. Much better to trigger off the live data.
alias: Email Freezer Temps YAML
description: ""
trigger:
- platform: numeric_state
entity_id:
- sensor.ibs_th2_p01b_09a6_temperature
- sensor.ibs_th2_p01b_06c1_temperature
- sensor.ibs_th2_p01b_15b8_temperature
above: -10
id: too warm
- platform: state
entity_id:
- sensor.ibs_th2_p01b_09a6_temperature
- sensor.ibs_th2_p01b_06c1_temperature
- sensor.ibs_th2_p01b_15b8_temperature
to:
- unknown
- unavailable
id: not available
action:
- service: notify.o365_email_o365tommy
data:
title: Freezer Test
message: The {{ trigger.to_state.name }} is {{ trigger.id }}.
mode: single
If you find that this is too lively and triggers e.g. when you’re reloading the freezer with the door open for a few minutes, you can add e.g. for: "00:05:00" to the numeric_state trigger to only fire if the temperature is exceeded for 5 minutes.
Thanks for the replies people. It’s obvious I don’t have much exposure to doing many automations. My normal approach is to find examples in the forums/reddit and go from there and unfortunately in this case this was not even a ChatGPT attempt but my own uneducated initial attempts
My thought on the “hourly” was that I just didn’t want to be spammed by emails if the conditions are met. But now I do see that having the 3 temperature checks in my “conditions” was also a rookie mistake as all 3 would have to be met.
@Troon thanks for taking the time to put together that example!
Cheers @Troon !
Should I be concerned about this warning? I did try and put double quotes around unknown and available like I see in the documentation examples but it doesn’t seem to stick?
The warning is fine to ignore: the UI is gradually improving but still has gaps versus YAML. You can see from the “title” that it understands the meaning. If it bothers you, you could duplicate it into one trigger for unknown and one for unavailable.
You can’t test automations manually when the trigger variable is used (docs).
I’m reading that triggers for a numeric state are for when my freezer temp “crosses” the threshold I set and then will not fire again until it moves out of that threshold and then meets it again.
If that is the case then how does the “for” option work for this trigger? I’m guessing it will only trigger one the temp moves past my threshold and is there for X time and the trigger will not fire again until the freezer goes to it’s expected temp and then crosses the threshold again?
for what it is worth here is how I tackled the same issue (have 3 fridges and 1 freezer with sensors inside)
created a group sensor with all four fridge sensors
use the below to identify the name of the fridge/freezer in error - to put that name in my home assistant message
used the below to identify how many fridges may be in error - to use this count in my dashboard. also in my dashboard I can turn the fridge icon red using the group fridge sensor or the ones below.
trigger my alert message on when the group temp is over x or when the count goes above 0.
the one flaw in my approach is I treat the freezer temp the same as fridge temp threshold, 45, in my count over 45 sensor below.
I welcome any suggestions to make this better.