Troubleshooting ESPHome and Gosund SP112

Hi All,

I’m troubleshooting a Gosund SP112 (EU) Power-Monitoring Plug flashed with Esphome.

Looking For Help On

How do I troubleshoot a plug that seems to randomly reboot after 30 mins or so.
I know because default behavior was to turn-on light on reboot. Light kept coming on.
Behavior seems to lose connection to server, and then reboot plug
I am looking for guidance on how to troubleshooting plug

Version Info

Home Assistant 2021.9.6
Version core-2021.9.6
client_info: ‘Home Assistant 2021.9.6’
esphome v2021.8.2

I have log file from esphome, but didn’t want to post for brevity.
Thank you in advance for any tips!
~Bryan

#################################
# From HomeAssistant Logbook
#   Devices is called Relay Mains, and reboots radomly after 30 or 15 mins.
#################################
Relay Mains turned off  	6:10:58 PM - 48 seconds ago
Relay Mains became unavailable	6:10:54 PM - 52 seconds ago
Relay Mains turned off		5:17:16 PM - 54 minutes ago
Relay Mains became unavailable	5:15:47 PM - 56 minutes ago
Relay Mains turned off		5:01:40 PM - 1 hour ago
Relay Mains became unavailable	5:01:06 PM - 1 hour ago
Relay Mains turned off		4:31:26 PM - 2 hours ago
Relay Mains became unavailable	4:31:24 PM - 2 hours ago
Relay Mains turned off		4:27:55 PM - 2 hours ago
Relay Mains became unavailable	4:27:45 PM - 2 hours ago

Esphome Config

substitutions:
  system_name: mbr_lamp
  friendly_name: MBR Lamp Plug
  device_description: "Used for lamp, and power management for Bryan's Side of Bed."
  restore_mode: ALWAYS_ON

esphome:
  name: ${system_name}
  platform: ESP8266
  arduino_version: 2.5.1
  board: esp01_1m
  on_boot:
    priority: -10  
    then:
      - switch.turn_off: switch1

<<: !include .common/common.yaml

# Enable logging
logger:
  level: VERY_VERBOSE   #DEBUG is the default

switch:

- platform: gpio
  name: "Relay Mains"
  id: switch1
  pin: GPIO14

- platform: gpio
  name: "Relay USB"
  id: switchusb
  restore_mode: ${restore_mode}
  pin:
    number: GPIO13
    inverted:  true

binary_sensor:
- platform: template
  id: button1
  name: "${friendly_name} Button 1"
  # read analog sensor and convert it's value to binary state
  lambda: return (id(button_adc).state < .5);
  on_click:
  # short button press toggles mains
  - min_length: 10ms
    max_length: 250ms
    then:
    - switch.toggle: switch1
  # long button press toggles USB
  - min_length: 250ms
    max_length: 1000ms
    then:
    - switch.toggle: switchusb

sensor:
- platform: adc
  id: button_adc
  pin: A0
  update_interval: 30s
- platform: hlw8012
  sel_pin:
    number: GPIO12
    inverted: True
  cf_pin: GPIO05
  cf1_pin: GPIO04
  current_resistor: 0.00221
  voltage_divider: 871
  change_mode_every: 8
  update_interval: 60s
  current:
    id: amperage
    name: "${friendly_name} Amperage"
    
  voltage:
    id: voltage
    name: "${friendly_name} Voltage"
    
  power:
    id: wattage
    name: "${friendly_name} Wattage"