Device Disconnected from Network, Still Shows in Router, No Ping, Unavailable in HA, Active in Addon

Hey everybody! I am hoping you guys can help me out!

I recently purchased a Wyze Outdoor Switch and promptly flashed ESPHome onto it by following the instructions here. It worked great for a few days, until it suddenly stopped working, without me doing anything to it. It shows active in the ESPHome Addon, but would be ‘Unavailable’ in HA.

I reflashed the device multiple times, and it would work for about a minute, and then stop responding again. My wifi network shows the device is connected, but it will not ping. HA also automatically discovers it when I plug it in, but when I go to the Integrations tab to set it up, I get this message: Can't connect to ESP. Please make sure your YAML file contains an 'api:' line. but the API is in the YAML file.

I have attached the YAML config here

substitutions:
  display_name: ESPHome Outdoor Switch 1
  # Higher value gives lower watt readout
  current_res: "0.001"
  # Lower value gives lower voltage readout
  voltage_div: "770"  
  
esphome:
  name: esphome_outdoor_switch_1
  platform: ESP32
  board: esp-wrover-kit

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
  power_save_mode: none
  manual_ip:
    static_ip: !secret outdoor_switch_1_ip
    gateway: !secret network_gateway
    subnet: !secret network_subnet
    dns1: !secret network_dns
  ap: 
    ssid: ${display_name} AP
    password: !secret ap_password
    
captive_portal:
logger:
api:
ota:
web_server:

switch:
  - platform: gpio
    name: ${display_name} Relay 1
    pin:
      number: GPIO15
      inverted: false
    id: relay1
    on_turn_on:
      - light.turn_on: relay1_led
    on_turn_off:
      - light.turn_off: relay1_led
  - platform: gpio
    name: ${display_name} Relay 2
    pin:
      number: GPIO32
      inverted: false
    id: relay2
    on_turn_on:
      - light.turn_on: relay2_led
    on_turn_off:
      - light.turn_off: relay2_led
  - platform: restart
    name: ${display_name} Restart

output:
  - platform: gpio
    pin: GPIO19
    inverted: True
    id: relay1_led_gpio
  - platform: gpio
    pin: GPIO16
    inverted: True
    id: relay2_led_gpio

light:
  - platform: binary
    name: "Relay 1 LED"
    id: relay1_led
    internal: true    
    output: relay1_led_gpio
  - platform: binary
    name: "Relay 2 LED"
    id: relay2_led
    internal: true
    output: relay2_led_gpio

sensor:
  - platform: adc
    pin: GPIO34
    name: "${display_name} LUX"
    update_interval: 10s
    attenuation: 11db
  - platform: hlw8012
    sel_pin:
      number: GPIO25
      inverted: true
    cf_pin: GPIO27
    cf1_pin: GPIO26
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    change_mode_every: 3
    update_interval: 3s    
    current:
      name: "${display_name} Amps"
      unit_of_measurement: A
      accuracy_decimals: 2
    voltage:
      name: "${display_name} Volts"
      unit_of_measurement: V
      accuracy_decimals: 1
    power:
      name: "${display_name} Watts"
      unit_of_measurement: W
      accuracy_decimals: 0    
      filters:
        - calibrate_linear:
            - 0.0 -> 0.0
            - 134 -> 58 

binary_sensor:
  - platform: gpio
    internal: true
    pin:
      number: GPIO18
      mode: INPUT_PULLDOWN
      inverted: True
    name: ${display_name} Button 1
    on_press:
      - switch.toggle: relay1
  - platform: gpio
    internal: true
    pin:
      number: GPIO17
      mode: INPUT_PULLDOWN
      inverted: True
    name: ${display_name} Button 2
    on_press:
      - switch.toggle: relay2

status_led:
  pin:
    number: GPIO5
    inverted: true

I cant get any logs from the ESPHome Config for the device, as it cannot connect.

Connect UART programmer to rx, tx and Gnd, same as when you programmed, just don’t use programming but read data with any terminal program. Then boot normally, you’ll see what’s coming from serial log at bootup. Maybe it will be some help.

. Not sure what a brownout is, but it also appears to be in a bootloop. Do you know what might cause this?

Hm… brownout happens when mcu doesn’t have enough power, in that case it resets itself. Check your power supply and consumption of external devices/sensors. Perhaps your 3.3v volgate colapses for some reason? When booting wifi connection can eat up well over 100mA…

It doesnt make sense that it wouldnt have enough power, its its being plugged directly into the wall

Yeah, you have the point… if device is new then i doubt it’s broken…hard to say… you can, just for test, decrease wifi power and see what happens.

Default power is 20, I put it on 15 and still same situation. Its really bizarre and it was working completely fine and then randomly stopped.

Google esp32 brownout and you will get tons of results. Mostly a defective capacitor.

I would check/replace capacitor, too. Altough, as i said, in a new device it’s pretty odd, it’s still not impossible. After all, one electric spike can be enough to damage it… and if device is “chinese, then… you know: all is possible.