My project monitors a number of fridges and I wish to have some alerts when any gets too warm.
I’m using ESPHome - each ESP has two DS18B20 sensors attached, and another ESP has digital inputs and outputs for a control panel. Here, there’s an Alarm LED, an audible buzzer and a Mute button.
All ESPs and their sensors are up and running and visible on the HA dashboard.
The idea is that if any fridge gets too warm for say >30 minutes then the LED lights up and the buzzer sounds. When the Mute button is pressed, the light stays on but the buzzer stops. More than one fridge might get too warm, but the buzzer doesn’t re-sound once muted. Only once all fridges are cold enough does the light go out and the buzzer is ready for the next alarm.
I achieved this once before in C++ using Blynk and so am approaching this with a “linear programming” mindset. I know this is not appropriate here.
My thinking has been to have an automation for each sensor to create an alarm condition for that sensor, and then another automation to poll the sensor automations to work the lights and buzzer, but I’m just not getting it.
What I would need would be some sort of “variable” that could store the state of each sensor’s alarm automation, for polling into the display automation. I have tried using the “last triggered” attribute without success.
I have fried my brain trying to get this working and could do with some helpful pointers. I’m not asking for free code, just a hint of the way forward…!
The whole project consists of five - near identical - NodeMCUs (ESP8266) and one configured to drive the indicator panel. There are 6 fridges and 4 freezers, all configured the same way, though I’ll use different temperature setpoints for alarms. Fridges have one LED and freezers another, though there’s one buzzer, and one mute. Irrelevant for the moment are the call button and healthy LED.
HA is installed on a new 64GB RaspberryPi 4 with A2 class micro SD: installed via Raspberry Pi imager.
All items are on the same subnet, and, with the exception of browsing devices, have static IPs.
Below (hopefully correctly formatted) are the YAMLs for Indicator and one of the “outstations”
Perhaps you have your own motivations for doing it in such a fashion, but it sounds overly complex for the goal. My application is residential, but I use aqara temperature sensors in all my fridges and freezers, and have push notifications sent (could just as easily be a tts or buzzer or whatever).
As for your goal of sound the alarm once and then reset once they are all cold again, I’d use a binary threshold sensor that is on if 1 or more alarms, and off if 0 alarms.
The you have only a single automation controlled by a single sensor, rather than trying to keep track of all your different automations.
Look into the Alert entity. Is does what you want, can notify in various ways, and can be snoozed while remaining on. I am using one exactly for the same purpose you want.