Setting up intermittent warning buzzer

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:

 

      switches:
        - pin: 8
          name: 'Warning buzzer'
          momentary: 500
          pause: 500
          repeat: 15

 However, I would like a continuous buzzer that stays on until the switch is switched off.  I have tried:

 

      switches:
        - pin: 8
          name: 'Warning buzzer'
          momentary: 500
          pause: 500
          repeat: -1

 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.

Any idea what I am doing wrong?

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.

Hi @mail2 @nate

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:


switch:
  - platform: gpio
    pin: $out
    id: warningbeep
    name: warning beep 1
    on_turn_on:
    - delay: 50ms
    - switch.turn_off: warningbeep

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?

Here is what I do to configure the buzzer in esphome I use for my door chirp:

Configure the output

output:

  • platform: ledc
    pin: GPIO13
    id: buzzer_output

switch:

  • platform: output
    name: ‘buzzer’
    id: buzzer
    output: buzzer_output
    on_turn_on:
    then:
    - output.turn_on: buzzer_output
    - output.ledc.set_frequency:
    id: buzzer_output
    frequency: “200Hz”
    - output.set_level:
    id: buzzer_output
    level: “100%”
    - delay: 80ms
    - output.turn_off: buzzer_output
    - delay: 70ms
    - output.turn_on: buzzer_output
    - output.ledc.set_frequency:
    id: buzzer_output
    frequency: “200Hz”
    - output.set_level:
    id: buzzer_output
    level: “100%”
    - delay: 80ms
    - output.turn_off: buzzer_output
    - switch.turn_off: buzzer

    on_turn_off:
    then:
    - output.turn_off: buzzer_output

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… :slight_smile:

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

switch:
  - platform: template
    name: "buzzer virtual switch"
    id: buzzervs
    restore_mode: always_off
    turn_on_action:
      - switch.turn_on: warningbeep
      - delay: 100ms
      - switch.turn_off: warningbeep
      - delay: 100ms
      - switch.turn_on: warningbeep
      - delay: 100ms
      - switch.turn_off: warningbeep
      - switch.turn_off: buzzervs

  - platform: gpio
    pin: $out
    name: 2nd_floor_buzzer
    id: warningbeepk2
    restore_mode: always_off

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:

substitutions:
  warning_beep_pulse_time: 50ms
  warning_beep_pause_time: 60ms

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:

button:
  - platform: template
    name: Two beeps
    on_press:
      - repeat:
          count: 2
          then:
            - output.turn_on: buzzer_output
            - delay: 50ms
            - output.turn_off: buzzer_output
            - delay: 50ms
    

Hi all, with the update to home assistant using ESPhome, I am unsure how to set the buzzer output to zone 5 on a 6 zone alarm panel conversion kit using the home assistant configuration?

I have read some articles saying I need to use a yaml file with the substitutions listed but I have no idea where to save this file and what to put in the code, there currently are no configuration files and the alarm is working fine but no buzzer configured.

Any assistance is appreciated.

Hello,
I also struggled to make the buzzer work on konnected 6-zone alarm panel together with the standard ESPhome buzzer output and HA. I used to receive following errors on validation: Pin incorrectly sets allow_other_uses: true.
I had almost given up, but at the end managed to configure zone5 as output in the following way.

  1. I copied everything over from the main repository file:
    konnected-esphome / alarm-panel-esp8266.yaml
  2. Put the needed substitutions. warning_beep_shared: ‘false’ was needed to be set as otherwise the validation was failing.
  3. Commented out the standard packages/alarm-panel/zone5.yaml file
  4. Commented out the standard packages/alarm-panel/alarm.yaml file, but added the needed content from the repository file (konnected-esphome/packages/alarm-panel/alarm.yaml)
  5. The above was due to the need to set allow_other_uses: false for siren . Otherwise the validation was failing.
  6. Added the soft button in the way @nate advised.
substitutions:
  name: ************
  friendly_name: *************
  warning_beep_pin: $zone5
  warning_beep_shared: 'false'
  warning_beep_pulse_time: 50ms
  warning_beep_pause_time: 1000ms

packages:

  remote_package:
    url: http://github.com/konnected-io/konnected-esphome
    ref: master
    refresh: 5min
    files:

      - packages/alarm-panel-esp8266-base.yaml
      - packages/alarm-panel/zone1.yaml
      - packages/alarm-panel/zone2.yaml
      - packages/alarm-panel/zone3.yaml
      - packages/alarm-panel/zone4.yaml
#      - packages/alarm-panel/zone5.yaml
      - packages/alarm-panel/zone6.yaml
#      - packages/alarm-panel/alarm.yaml

      - packages/wifi.yaml

      - packages/warning-beep.yaml

      - packages/status-led.yaml

dashboard_import:
  package_import_url: github://konnected-io/konnected-esphome/alarm-panel-esp8266.yaml@master
  import_full_config: false

esphome:
  name: ${name}
  name_add_mac_suffix: false
  friendly_name: ${friendly_name}

switch:
  - id: siren
    name: Siren
    pin:
      number: $alarm
      allow_other_uses: false
    platform: gpio
    icon: mdi:bullhorn

button:
  - platform: template
    name: Two beeps
    on_press:
      - repeat:
          count: 2
          then:
            - output.turn_on: buzzer_output
            - delay: 50ms
            - output.turn_off: buzzer_output
            - delay: 200ms

web_server:
  include_internal: true

logger:

api:
  encryption:
    key: **************

ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  • Comments removed above for better readability.

After having all this, the Two beeps switch appeared as entity under ESPhome in HA.
Still haven’t tested the siren, so I will update if any further modifications were needed.

Thanks to all previous hints in this thread!

1 Like