I am using a couple of ESP8266 boards with Home Assistant for sensors and alarms. All is working fine.
I have just added a 3.3v piezo buzzer to pin 8 of one of my boards to use as an alarm pending warning. The buzzer works fine if set up as a continuous sounder. I would like to set it up as an intermittent warning buzzer. The following code works fine:
As per the documentation. With this setup, the buzzer sounds only once and then stops. The switch in HA acts as a momentary switch, and turns off about a second after turning on.
Figured this out (thanks Nate). The beep feature was added in a later version of the firmware - I have updated all of my boards and they are now working as expected.
I hope that it is ok that I ask here even though this is an old topic. Did the commands changed a bit since you posted here? I get some errors with your code.
I would like to set up my buzzer to give 2 beeps every time it is turned on. It was one of the options with the konnected firmware. From what I read, I could use a momentary switch to get one beep:
Could you please advise me on how to combine it with the repeat action to get a double beep? I am very new to ESPhome. I can think of some kind of virtual switch that is triggered when the warningbeep switch is turned on and then if the virtual switch is turned on: delay 50ms → switch.warningbeep OFF, delay 50ms, ON, delay 50ms, OFF, turn the virtual switch OFF but is there a cleaner way?
Thank you! I have couple of questions to make sure that I understand this correctly. Why are you using the ledc platform? To modulate the frequency? I am using the simplest possible buzzer where I can only have it on or off. In such case, would you still recommend using platform: ledc?
Anyway, it seems like a virtual switch would is the best solution. I just tried this and it works as it should! I am not sure if it is the best solution but as long as it works…
Now I am wondering if it is possible to trigger a buzzer if a sensor wired to another ESP is triggered. Then I could move more automations to ESPHome
If you’re using Konnected’s ESPHome packages, there’s a built in warning_beep that acts as a light entity so we can use the strobe effect to make it beep repeatedly until turned off. This is already built-in! Just turn it on and off like this:
- light.turn_on:
id: warning_beep
effect: strobe
You can change how fast the beeps are by setting the substitution variable warning_beep_pulse_time and warning_beep_pause_time:
Pulse is the duration of the beep and pause is the time between beeps.
To make a buzzer that makes only X beeps every time it’s pressed, I my suggestion would be to create a button template that activates the buzzer_output in your desired pattern on press: