I’m in the process of switching from using Xbees to esp32-C6s. So, this is the first project built on the esp platform.
The goal was to monitor 4 freezers that sit side by side and get alerts if one was to fail and to do this using Zigbee.
There were a few things that took a bit to get right. First, we can’t guarantee that the sensors are found in the same order on every boot, so we need to save the address and associated end point to flash. I am also giving one of these to my father, so I wanted to be able to swap out a ds18b20 if it failed without re-flashing the esp. The device accomplishes this by searching for available sensors, assigning them to endpoints and saving the results to flash. If a sensor is not found on boot, its record is erased and if there is a new sensor, replaced with that address.
Also, I wanted to ensure that if the circuit powering the freezers failed and since this is plugged into a phone charger and not battery powered, that I would get an alert before ZHA marked the device as unavailable. To that end, we have a binary heart beat sensor. The device flips the state every 30 seconds so that we can use the last changed in an automation.
Github Repo: prairiesnpr/esp_zha_freezer_mon (github.com)
Example Automation:
alias: Notify if freezer fails
id: 9650f049-dc99-43de-a3fb-e2c17ba2f96a
trigger:
- platform: template
value_template: >-
{{ (now() -
states.binary_sensor.isilentllc_freezer_monitor_binary_input_2.last_changed).seconds
> 300 }}
variables:
reason: "no update in the last 5 minutes"
- platform: numeric_state
entity_id:
- sensor.isilentllc_freezer_monitor_temperature_5
for:
hours: 0
minutes: 5
seconds: 0
above: -5
variables:
reason: "temperature is {{state.state}} which is above -5° F"
action:
- service: notify.all_ios_devices
data_template:
title: 'Garage Freezer Failed!'
message: 'Garage Freezer Failed, {{reason}}.'
- service: notify.all_android_devices
data_template:
title: 'Garage Freezer Failed!'
message: 'Garage Freezer Failed, {{reason}}.'
In the ZHA UI, sorry, room temp for this screenshot.
Circuit, random minifig for scale, and yes, I ran out of 4.7kohm resistors: