I have an ESP32 based home alarm system configured and working flawlessly since a few months. I have 6 wired door sensors hooked up to the ESP32. There are two active relay connected buzzers (one in entry door and one in the basement) which beep on a door open/close automation in Home Assistant. The beeps templates are defined in ESPHome and are programmed into the ESP32. However the automation or simple door open/close trigger is in Home Assistant. So both buzzers beep simultaneously on door open/close. I want to move the logic of just the door open/close beep to ESP32. So in case my Home Assistant machine is down for whatever reason, the door beeps at least work. Online I see some scripts based on Arduino but nothing for ESPHome.
Here is part of the relevant config in ESP32. Would appreciate if someone can help me with a simple door open/close code for ESPHome.
So beep1 and beep2 are the two active buzzers and open_beep1/close_beep1 open_beep2/close_beep2 are the beeps template defined for multiple beeps (door open) and single long beep (door close). Both buzzers should beep simultaneously on door open/close.
I would like the automation moved from HA to ESP32 in case my system goes offline. Any help would be highly appreciated.
@Mahko_Mahko … perhaps it might be quite simple. Just an automation to run when the binary sensors, Front Door and Front Door Porch changes state? I do get lost in very long questions.
Thanks for the link. I got it working for on-press and on-release. I had to add this for each sensor. To simplify the code can I consolidate the on-press and on-release for a defined sensors under a single group?
Thank you! I will update my code accordingly. Right now I am using two 12v active buzzers which is causing my Esp32 to reboot. I have ordered two passive buzzers and expecting delivery any day. Your code will help me a lot for switching from active to passive.
Also, I think your code indentation was changed while posting. Could you please add ``` to the start and end of your code. That will preserve the indentations. Thank you once again!
So here is what I have now. I had to change from esp8266_pwm to ledc as I have ESP32. Also I have defined the frequency aspects of the code to single outputs beep1 and beep2 and then defined what beep1 and beep2 should sound like via template. This still does not resolve the grouping issue. I would like to group the doors together so that I don’t have to add the open/close beeps for each door sensor.
Hi! Thank you for your post! I also have an ESP based alarm system, mine is from Konencted and I just re-flashed their boards with ESPHome. That was also my first contact with ESPHome so I am very new to it. I have two questions:
Is a template the only option to get multiple beeps from the buzzer? What I would like to get is 2 beeps every time the switch is turned on. For now I am ok with HA triggering an automation where if a door/window sensor is triggered, a switch controlling the buzzer is turned on (but see question 2). I managed with a single beep easily by defining the switch as a momentary switch but struggle to get the double beep action. Ideally I would like a momentary switch with a repeat action.
Is there a way to have an automation on an ESP to trigger buzzers wired to different ESPs when one of the sensors wired to one of the ESPs gets triggered? I would like to get a beep from all of the buzzers throughout the house, not only from the one that is wired to the ESP to which the sensor that was triggered is connected. That’s why I moved the automation back to HA.