ESP32 Garage Door Opener randomly offline

My garage door opener randomly goes offline in Home Assistant(I can still ping it so it’s connected to wifi still). When I go into ESPHome I can’t connect to it via the esphome api. It will then randomly come back online but keeps doing this throughout the day randomly.

The weird thing is that I had the same issue with a Meross garage door opener which was connected via Apple Homekit to Home Assistant. I have a Crafstman garage door opener if that helps.

I have it connected to 1 relay with an esp32 just like the diagram below except minus the one reed sensor(I only have 1 connected).

Here is my code:

esphome:
  name: garage
  friendly_name: Garage

esp32:
  board: esp32dev
  framework:
    type: arduino

debug:
  update_interval: 5s

text_sensor:
  - platform: debug
    device:
      name: "Device Info"
    reset_reason:
      name: "Reset Reason"  

# Enable logging
logger:
  level: debug

# Enable Home Assistant API
api:
  encryption:
    key: "XXXXXXXXXXXXXXXXXXXXXXXX"

ota:
  - platform: esphome
    password: "XXXXXXXXXXXXXXXXXXXX"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 172.16.20.9
    gateway: 172.16.20.1
    dns1: 172.16.20.1
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Garage Fallback Hotspot"
    password: "XXXXXXXXX

captive_portal:

switch:
  - platform: gpio
    pin: GPIO4
    name: " Switch"
    id: garage_switch
    restore_mode: ALWAYS_OFF

binary_sensor:
  # This is the magnetic reed switch, used to determine if the door is closed.
  - platform: gpio
    pin: 
      number: GPIO13
      mode: INPUT_PULLUP
    filters:
      # During testing- the reed switch was pretty noisy. This cleans up the output.
      - delayed_on: 100ms
      - delayed_off: 100ms
    id: reed_switch
    internal: true

cover:
  - platform: template
    name: "Door"
    lambda: |-
      if (id(reed_switch).state) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      }
    open_action:
      - switch.turn_on: garage_switch
      - delay: 0.5s
      - switch.turn_off: garage_switch
    close_action:
      - switch.turn_on: garage_switch
      - delay: 0.5s
      - switch.turn_off: garage_switch

You left out the most important part - the wifi & api section.

Post the full yaml and make sure to hide sensitive stuff like your wifi credentials and encryption key.

Ah my bad, it’s now all posted :slight_smile:

No worries. Here’s the wifi section from one of my problematic ESP8266 (yes, the ancient ones). Hopefully it’ll help, but double check the ESPHome docs whether the options I added are compatible with the ESP32:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  manual_ip:
    static_ip: 192.168.1.80
    gateway: 192.168.1.1
    subnet: 255.255.255.0
  fast_connect: true
  output_power: 20.4 dB
  power_save_mode: none

In my case, it resolved most issues. It would still drop out whenever I switched on a PS4 on 5GHz wifi 2 floors down (probably bluetooth interference), but the problem went away when I got a PS5.
If the above doesn’t fix your issues, pay attention to what’s turning on and off during the times it goes unavailable. It took me a few months to realise the unavailable timestamps matched up with when I had my PS4 running.

Can you check signal strength on the esp. should show in logs or webpage

If it’s dropping connection it may also be rebooting as result

Like recommended. Maybe just need change power save to none

Thanks for the reply!

I made those changes and I think it’s actually fixed now!?

Home Assistant is still showing it going offline but only for about 30 seconds then comes back and I don’t even notice it now as it would previously go offline for hours on end. Still super strange since I don’t have any of these issues with the 10 other ESP devices in my house but thanks for posting that code as it looks like it’s fixed now!

1 Like