ESPhome and Home Assistant automations

Hi! I would like to switch from Konnected firmware to the ESPHome. I have one spare board and I easily flashed it with ESPHome. It got discovered and added to HA and all the zones are visible - great! I then used the ESPHome add-on and through the “Adopt” option got access to edit the yaml on the device. I managed to change the friendly name, tried setting the beep pulse time and beep pause time but I am not sure if that worked. When I turn on the switch for the buzzer, it just stays on continuously but maybe if used in an automation, it would be ok.

I read in one of the Konnected’s posts that one of the advantages of using the ESPHome firmware is that I can have automations directly on the board if I understand it correctly. Currently, I have an automation in HA that triggers a short double beep every time a door/window is opened. I have several buzzers and it is a bit annoying that they do not beep at the same time due to some kind of delays. It would be great to test this with an automation directly on the device.

Any tips on how to get started with writing such automation for the ESPHome? I have never worked with EPSHome before. If this works really well, I would be happy to move my more of “alarm” type of automations like the siren etc.

1 Like

Here’s how I would add a local automation to beep the buzzer any time the door is open. I’m doing this by extending Zone 1 that is defined in Konnected’s firmware config. All you need to do is add this to your YAML file after adopting. If you wanted it to work on multiple zones, just add more extend entries under binary_sensor for each zone:

# Extend a zone to beep when opened
  - id: !extend zone1
      - if:
            lambda: return x;
            - two_beeps

# Button when pressed makes two beeps
  - platform: template
    name: Two beeps
    id: two_beeps
      - repeat:
          count: 2
            - output.turn_on: buzzer_output
            - delay: 50ms
            - output.turn_off: buzzer_output
            - delay: 50ms

Let me know how this works! This seems like something useful to add as a package in the default firmware.

Hi Nate,

I am very sorry for replying with such a delay and thank you so much for your reply and help.
It works perfectly for me! I think that it would be valuable for other users as well. I am sure that your user base is a lot more advanced in programming in general and ESPHome than a random group of people on the street but I would guess that there are also some people who are at the beginning of the smart home journey. They would for sure, like me, appreciate more instructions :slight_smile:

From my perspective, it would be great to get even more clarification in some of the tutorials. For example why/how to use lambda in the condition or what to replace the “output.turn_on” with (as in that it is an example and you could have a switch there etc.). At the same time I understand that you are not educating people on how to work with ESPHome. I really enjoyed learning some basics and your example was very helpful.