Smart Doorbell - notify HA when ESP returns from deepsleep

Dear all

In our multi-appartment building we have an old doorbell system (1970s) from Koch (Model K933UP). My goal is to be able to open the main-door from HA without modifying the existing system too much.

I started based on the following project:

I used a D1 mini board with a relay shield as ESP and configured it appropriately with ESPhome.

As I use a 18650 battery as power source, I put the ESP into deep sleep when not in use.

Once the bell rings, the D1 is woken up from deep sleep and connects to wifi (which happens quite fast). However it takes some time till HA connects again and you can control the entities via HA. Is there any way to speed this part up?

Maybe using mqtt can be faster because the ESP know the IP of the broker. With HA protocol, is HA how find new ESP’s

Thanks - I just had another idea: notify HA via a webhook once the device is online.

I therefore used the web_server functionality on the ESP and the automation/webhook/script functionality on HA.

The config looks as follows on the ESP side:

    - while:
        - delay: 1s

And on HA:

automations.yaml - expects action=[on|off]

alias: Toggle door opener ESP helper-state when webhook is called
description: ''
  - platform: webhook
    webhook_id: door-opener-esp
condition: []
  - service: 'input_boolean.turn_{{ trigger.query["action"] }}'
    data: {}
    entity_id: input_boolean.door_opener_esp_online
mode: single


  turn_on_door_buzzer: curl -X POST
  turn_off_door_buzzer: curl -X POST


  alias: Door Opener 4s
  - condition: state
    entity_id: input_boolean.door_opener_esp_online
    state: 'on'
  - service: shell_command.turn_on_door_buzzer
    data: {}
  - service: tts.google_say
      entity_id: media_player.sonos_bedroom
      message: Door has been opened.
  - wait_template: ''
    timeout: 00:00:04
    continue_on_timeout: true
  - service: shell_command.turn_off_door_buzzer
    data: {}
  mode: single
  icon: mdi:door-open