Last Boot was an unhandled reset, will proceed to safe mode in 8 restarts

I have an ESPHome device (ESP32) with 4 relays, 4 switches and a temp&humidity sensor

If I turn the relays on-off fast, then the ESP32 seems to reboot or disconnect. For example:

[07:16:59][C][captive_portal:088]: Captive Portal:
[07:16:59][C][mdns:084]: mDNS:
[07:16:59][C][mdns:085]:   Hostname: lightscontrol-1
[07:16:59][C][ota:085]: Over-The-Air Updates:
[07:16:59][C][ota:086]:   Address: lightscontrol-1.local:3232
[07:16:59][C][ota:089]:   Using Password.
[07:16:59][W][ota:095]: Last Boot was an unhandled reset, will proceed to safe mode in 8 restarts
[07:16:59][C][api:138]: API Server:
[07:16:59][C][api:139]:   Address: lightscontrol-1.local:6053
[07:16:59][C][api:143]:   Using noise encryption: NO

Or

[07:25:59][D][switch:017]: 'relay_3' Turning OFF.
INFO lightscontrol-1.local: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for lightscontrol-1.local
WARNING Disconnected from API
INFO lightscontrol-1.local: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Successfully connected to lightscontrol-1.local

Is that normal? is it getting overloaded?

No

Maybe, but the log before it reset would be more use.

Here is a full log, with 3 [Errno 104]

Something interesting is that it walways happen when trying to turn the relay off:
[switch:017]: ‘relay_3’ Turning OFF

My config is a bit complicated at first sight
full config: electronics-homeassistant-lightscontroll/EspHome.yml at deeba4f41c192b5925ff4604e7a4fd0c6efa2736 · crgarcia12/electronics-homeassistant-lightscontroll · GitHub

I am using a template because the lights can be turned on/off manually as well, so I need to “read” the state of the light from a binary_sensor

INFO Reading configuration /config/esphome/lightscontrol-1.yaml...
INFO Starting log output from lightscontrol-1.local using esphome API
INFO Successfully connected to lightscontrol-1.local
[08:29:36][I][app:102]: ESPHome version 2022.5.1 compiled on Jun 15 2022, 14:43:14
[08:29:36][C][wifi:491]: WiFi:
[08:29:36][C][wifi:353]:   Local MAC: 
[08:29:36][C][wifi:354]:   SSID: 'xxxx'[redacted]
[08:29:36][C][wifi:355]:   IP Address: xxxx
[08:29:36][C][wifi:357]:   BSSID: xxxx[redacted]
[08:29:36][C][wifi:358]:   Hostname: 'lightscontrol-1'
[08:29:36][C][wifi:360]:   Signal strength: -56 dB ▂▄▆█
[08:29:36][C][wifi:364]:   Channel: 11
[08:29:36][C][wifi:365]:   Subnet: 255.255.255.0
[08:29:36][C][wifi:366]:   Gateway: xxxx
[08:29:36][C][wifi:367]:   DNS1: xxxx
[08:29:36][C][wifi:368]:   DNS2: 0.0.0.0
[08:29:36][C][logger:274]: Logger:
[08:29:36][C][logger:275]:   Level: DEBUG
[08:29:36][C][logger:276]:   Log Baud Rate: 115200
[08:29:36][C][logger:277]:   Hardware UART: UART0
[08:29:36][C][i2c.arduino:038]: I2C Bus:
[08:29:36][C][i2c.arduino:039]:   SDA Pin: GPIO21
[08:29:36][C][i2c.arduino:040]:   SCL Pin: GPIO22
[08:29:36][C][i2c.arduino:041]:   Frequency: 10000 Hz
[08:29:36][C][i2c.arduino:044]:   Recovery: bus successfully recovered
[08:29:36][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'sensor_1'
[08:29:36][C][gpio.binary_sensor:016]:   Pin: GPIO32
[08:29:36][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'sensor_2'
[08:29:36][C][gpio.binary_sensor:016]:   Pin: GPIO35
[08:29:36][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'sensor_3'
[08:29:36][C][gpio.binary_sensor:016]:   Pin: GPIO34
[08:29:36][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'sensor_4'
[08:29:36][C][gpio.binary_sensor:016]:   Pin: GPIO39
[08:29:36][C][switch.gpio:050]: GPIO Switch 'test_light'
[08:29:36][C][switch.gpio:051]:   Pin: GPIO23
[08:29:36][C][switch.gpio:073]:   Restore Mode: Restore (Defaults to OFF)
[08:29:37][C][template.switch:058]: Template Switch 'light_1'
[08:29:37][C][template.switch:058]:   Icon: 'mdi:ceiling-light'
[08:29:37][C][template.switch:059]:   Restore State: NO
[08:29:37][C][template.switch:060]:   Optimistic: NO
[08:29:37][C][template.switch:058]: Template Switch 'light_2'
[08:29:37][C][template.switch:058]:   Icon: 'mdi:ceiling-light'
[08:29:37][C][template.switch:059]:   Restore State: NO
[08:29:37][C][template.switch:060]:   Optimistic: NO
[08:29:37][C][template.switch:058]: Template Switch 'light_3'
[08:29:37][C][template.switch:058]:   Icon: 'mdi:ceiling-light'
[08:29:37][C][template.switch:059]:   Restore State: NO
[08:29:37][C][template.switch:060]:   Optimistic: NO
[08:29:37][C][template.switch:058]: Template Switch 'light_4'
[08:29:37][C][template.switch:058]:   Icon: 'mdi:ceiling-light'
[08:29:37][C][template.switch:059]:   Restore State: NO
[08:29:37][C][template.switch:060]:   Optimistic: NO
[08:29:37][C][switch.gpio:050]: GPIO Switch 'relay_1'
[08:29:37][C][switch.gpio:051]:   Pin: GPIO13
[08:29:37][C][switch.gpio:073]:   Restore Mode: Restore (Defaults to OFF)
[08:29:37][C][switch.gpio:050]: GPIO Switch 'relay_2'
[08:29:37][C][switch.gpio:051]:   Pin: GPIO27
[08:29:37][C][switch.gpio:073]:   Restore Mode: Restore (Defaults to OFF)
[08:29:37][C][switch.gpio:050]: GPIO Switch 'relay_3'
[08:29:37][C][switch.gpio:051]:   Pin: GPIO26
[08:29:37][C][switch.gpio:073]:   Restore Mode: Restore (Defaults to OFF)
[08:29:37][C][switch.gpio:050]: GPIO Switch 'relay_4'
[08:29:37][C][switch.gpio:051]:   Pin: GPIO25
[08:29:37][C][switch.gpio:073]:   Restore Mode: Restore (Defaults to OFF)
[08:29:37][C][sht4x:050]:   Address: 0x44
[08:29:37][C][captive_portal:088]: Captive Portal:
[08:29:37][C][mdns:084]: mDNS:
[08:29:37][C][mdns:085]:   Hostname: lightscontrol-1
[08:29:37][C][ota:085]: Over-The-Air Updates:
[08:29:37][C][ota:086]:   Address: lightscontrol-1.local:3232
[08:29:37][C][ota:089]:   Using Password.
[08:29:37][C][api:138]: API Server:
[08:29:37][C][api:139]:   Address: lightscontrol-1.local:6053
[08:29:37][C][api:143]:   Using noise encryption: NO
[08:30:03][D][switch:013]: 'light_3' Turning ON.
[08:30:03][D][main:444]: template.turn_on.sensor==off
[08:30:03][D][switch:013]: 'relay_3' Turning ON.
[08:30:03][D][switch:037]: 'relay_3': Sending state ON
[08:30:03][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:30:03][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:30:03][D][switch:037]: 'light_2': Sending state ON
[08:30:03][D][switch:037]: 'light_3': Sending state ON
[08:30:03][D][switch:017]: 'relay_3' Turning OFF.
[08:30:03][D][switch:037]: 'relay_3': Sending state OFF
[08:30:03][D][switch:017]: 'light_3' Turning OFF.
[08:30:03][D][main:168]: template.turn_off.sensor==on
[08:30:03][D][switch:013]: 'relay_3' Turning ON.
[08:30:03][D][switch:037]: 'relay_3': Sending state ON
[08:30:03][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:30:03][D][switch:037]: 'light_3': Sending state OFF
[08:30:03][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:30:03][D][switch:037]: 'light_2': Sending state OFF
[08:30:03][D][switch:017]: 'relay_3' Turning OFF.
[08:30:03][D][switch:037]: 'relay_3': Sending state OFF
[08:30:04][D][switch:013]: 'light_3' Turning ON.
[08:30:04][D][main:444]: template.turn_on.sensor==off
[08:30:04][D][switch:013]: 'relay_3' Turning ON.
[08:30:04][D][switch:037]: 'relay_3': Sending state ON
[08:30:04][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:30:04][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:30:04][D][switch:037]: 'light_2': Sending state ON
[08:30:04][D][switch:037]: 'light_3': Sending state ON
[08:30:04][D][switch:017]: 'relay_3' Turning OFF.
[08:30:04][D][switch:037]: 'relay_3': Sending state OFF
[08:30:05][D][switch:017]: 'light_3' Turning OFF.
[08:30:05][D][main:168]: template.turn_off.sensor==on
[08:30:05][D][switch:013]: 'relay_3' Turning ON.
[08:30:05][D][switch:037]: 'relay_3': Sending state ON
[08:30:05][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:30:05][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:30:05][D][switch:037]: 'light_2': Sending state OFF
[08:30:05][D][switch:037]: 'light_3': Sending state OFF
[08:30:05][D][switch:017]: 'relay_3' Turning OFF.
[08:30:05][D][switch:037]: 'relay_3': Sending state OFF
[08:30:05][D][switch:013]: 'light_3' Turning ON.
[08:30:05][D][main:444]: template.turn_on.sensor==off
[08:30:05][D][switch:013]: 'relay_3' Turning ON.
[08:30:05][D][switch:037]: 'relay_3': Sending state ON
[08:30:05][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:30:05][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:30:06][D][switch:037]: 'light_2': Sending state ON
[08:30:06][D][switch:037]: 'light_3': Sending state ON
[08:30:06][D][switch:017]: 'relay_3' Turning OFF.
[08:30:06][D][switch:037]: 'relay_3': Sending state OFF
[08:30:06][D][switch:017]: 'light_3' Turning OFF.
[08:30:06][D][main:168]: template.turn_off.sensor==on
[08:30:06][D][switch:013]: 'relay_3' Turning ON.
[08:30:06][D][switch:037]: 'relay_3': Sending state ON
[08:30:06][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:30:06][D][switch:037]: 'light_3': Sending state OFF
[08:30:06][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:30:06][D][switch:037]: 'light_2': Sending state OFF
[08:30:06][D][switch:017]: 'relay_3' Turning OFF.
[08:30:06][D][switch:037]: 'relay_3': Sending state OFF
[08:30:06][D][switch:013]: 'light_3' Turning ON.
[08:30:06][D][main:444]: template.turn_on.sensor==off
[08:30:06][D][switch:013]: 'relay_3' Turning ON.
[08:30:06][D][switch:037]: 'relay_3': Sending state ON
[08:30:06][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:30:06][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:30:06][D][switch:037]: 'light_2': Sending state ON
[08:30:06][D][switch:037]: 'light_3': Sending state ON
[08:30:06][D][switch:017]: 'relay_3' Turning OFF.
INFO lightscontrol-1.local: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for lightscontrol-1.local
WARNING Disconnected from API
INFO lightscontrol-1.local: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Successfully connected to lightscontrol-1.local
[08:30:44][D][esp32.preferences:114]: Saving preferences to flash...
[08:30:50][D][sensor:125]: 'Temperature': Sending state 32.42085 °C with 2 decimals of accuracy
[08:30:50][D][sensor:125]: 'Relative Humidity': Sending state 36.53452 % with 2 decimals of accuracy
[08:30:56][D][switch:017]: 'light_3' Turning OFF.
[08:30:56][D][main:168]: template.turn_off.sensor==on
[08:30:56][D][switch:013]: 'relay_3' Turning ON.
[08:30:56][D][switch:037]: 'relay_3': Sending state ON
[08:30:56][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:30:56][D][switch:037]: 'light_3': Sending state OFF
[08:30:56][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:30:56][D][switch:037]: 'light_2': Sending state OFF
[08:30:56][D][switch:017]: 'relay_3' Turning OFF.
[08:30:56][D][switch:037]: 'relay_3': Sending state OFF
[08:30:56][D][switch:013]: 'light_3' Turning ON.
[08:30:56][D][main:444]: template.turn_on.sensor==off
[08:30:56][D][switch:013]: 'relay_3' Turning ON.
[08:30:56][D][switch:037]: 'relay_3': Sending state ON
[08:30:56][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:30:56][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:30:57][D][switch:037]: 'light_2': Sending state ON
[08:30:57][D][switch:037]: 'light_3': Sending state ON
[08:30:57][D][switch:017]: 'relay_3' Turning OFF.
INFO lightscontrol-1.local: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for lightscontrol-1.local
WARNING Disconnected from API
INFO lightscontrol-1.local: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Successfully connected to lightscontrol-1.local
[08:31:11][D][switch:017]: 'light_3' Turning OFF.
[08:31:11][D][main:168]: template.turn_off.sensor==on
[08:31:11][D][switch:013]: 'relay_3' Turning ON.
[08:31:11][D][switch:037]: 'relay_3': Sending state ON
[08:31:11][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:11][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:11][D][switch:037]: 'light_2': Sending state OFF
[08:31:11][D][switch:037]: 'light_3': Sending state OFF
[08:31:11][D][switch:017]: 'light_3' Turning OFF.
[08:31:11][D][main:436]: template.turn_off.sensor==off
[08:31:11][D][switch:017]: 'relay_3' Turning OFF.
[08:31:11][D][switch:037]: 'relay_3': Sending state OFF
[08:31:11][D][switch:013]: 'light_3' Turning ON.
[08:31:11][D][main:444]: template.turn_on.sensor==off
[08:31:11][D][switch:013]: 'relay_3' Turning ON.
[08:31:11][D][switch:037]: 'relay_3': Sending state ON
[08:31:11][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:11][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:11][D][switch:037]: 'light_2': Sending state ON
[08:31:11][D][switch:037]: 'light_3': Sending state ON
[08:31:11][D][switch:013]: 'light_3' Turning ON.
[08:31:11][D][main:449]: template.turn_on.sensor==on
[08:31:11][D][switch:017]: 'relay_3' Turning OFF.
[08:31:11][D][switch:037]: 'relay_3': Sending state OFF
[08:31:11][D][switch:017]: 'light_3' Turning OFF.
[08:31:11][D][main:168]: template.turn_off.sensor==on
[08:31:11][D][switch:013]: 'relay_3' Turning ON.
[08:31:11][D][switch:037]: 'relay_3': Sending state ON
[08:31:12][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:12][D][switch:037]: 'light_3': Sending state OFF
[08:31:12][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:12][D][switch:037]: 'light_2': Sending state OFF
[08:31:12][D][switch:017]: 'light_3' Turning OFF.
[08:31:12][D][main:436]: template.turn_off.sensor==off
[08:31:12][D][switch:017]: 'relay_3' Turning OFF.
[08:31:12][D][switch:037]: 'relay_3': Sending state OFF
[08:31:12][D][switch:013]: 'light_3' Turning ON.
[08:31:12][D][main:444]: template.turn_on.sensor==off
[08:31:12][D][switch:013]: 'relay_3' Turning ON.
[08:31:12][D][switch:037]: 'relay_3': Sending state ON
[08:31:12][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:12][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:12][D][switch:037]: 'light_2': Sending state ON
[08:31:12][D][switch:037]: 'light_3': Sending state ON
[08:31:12][D][switch:013]: 'light_3' Turning ON.
[08:31:12][D][main:449]: template.turn_on.sensor==on
[08:31:12][D][switch:017]: 'relay_3' Turning OFF.
[08:31:12][D][switch:037]: 'relay_3': Sending state OFF
[08:31:12][D][switch:017]: 'light_3' Turning OFF.
[08:31:12][D][main:168]: template.turn_off.sensor==on
[08:31:12][D][switch:013]: 'relay_3' Turning ON.
[08:31:12][D][switch:037]: 'relay_3': Sending state ON
[08:31:12][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:12][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:12][D][switch:037]: 'light_2': Sending state OFF
[08:31:12][D][switch:037]: 'light_3': Sending state OFF
[08:31:12][D][switch:017]: 'relay_3' Turning OFF.
[08:31:12][D][switch:037]: 'relay_3': Sending state OFF
[08:31:12][D][switch:017]: 'light_3' Turning OFF.
[08:31:12][D][main:436]: template.turn_off.sensor==off
[08:31:13][D][switch:013]: 'light_3' Turning ON.
[08:31:13][D][main:444]: template.turn_on.sensor==off
[08:31:13][D][switch:013]: 'relay_3' Turning ON.
[08:31:13][D][switch:037]: 'relay_3': Sending state ON
[08:31:13][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:13][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:13][D][switch:037]: 'light_2': Sending state ON
[08:31:13][D][switch:037]: 'light_3': Sending state ON
[08:31:13][D][switch:017]: 'relay_3' Turning OFF.
[08:31:13][D][switch:037]: 'relay_3': Sending state OFF
[08:31:13][D][switch:017]: 'light_3' Turning OFF.
[08:31:13][D][main:168]: template.turn_off.sensor==on
[08:31:13][D][switch:013]: 'relay_3' Turning ON.
[08:31:13][D][switch:037]: 'relay_3': Sending state ON
[08:31:13][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:13][D][switch:037]: 'light_3': Sending state OFF
[08:31:13][D][switch:017]: 'light_3' Turning OFF.
[08:31:13][D][main:436]: template.turn_off.sensor==off
[08:31:13][D][switch:017]: 'relay_3' Turning OFF.
[08:31:13][D][switch:037]: 'relay_3': Sending state OFF
[08:31:13][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:13][D][switch:037]: 'light_2': Sending state OFF
[08:31:14][D][switch:013]: 'light_3' Turning ON.
[08:31:14][D][main:444]: template.turn_on.sensor==off
[08:31:14][D][switch:013]: 'relay_3' Turning ON.
[08:31:14][D][switch:037]: 'relay_3': Sending state ON
[08:31:14][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:14][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:14][D][switch:037]: 'light_2': Sending state ON
[08:31:14][D][switch:037]: 'light_3': Sending state ON
[08:31:14][D][switch:013]: 'light_3' Turning ON.
[08:31:14][D][main:449]: template.turn_on.sensor==on
[08:31:14][D][switch:017]: 'relay_3' Turning OFF.
[08:31:14][D][switch:037]: 'relay_3': Sending state OFF
[08:31:14][D][switch:017]: 'light_3' Turning OFF.
[08:31:14][D][main:168]: template.turn_off.sensor==on
[08:31:14][D][switch:013]: 'relay_3' Turning ON.
[08:31:14][D][switch:037]: 'relay_3': Sending state ON
[08:31:14][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:14][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:14][D][switch:037]: 'light_2': Sending state OFF
[08:31:14][D][switch:037]: 'light_3': Sending state OFF
[08:31:14][D][switch:017]: 'relay_3' Turning OFF.
[08:31:14][D][switch:037]: 'relay_3': Sending state OFF
[08:31:14][D][switch:017]: 'light_3' Turning OFF.
[08:31:14][D][main:436]: template.turn_off.sensor==off
[08:31:14][D][switch:013]: 'light_3' Turning ON.
[08:31:14][D][main:444]: template.turn_on.sensor==off
[08:31:14][D][switch:013]: 'relay_3' Turning ON.
[08:31:14][D][switch:037]: 'relay_3': Sending state ON
[08:31:14][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:14][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:14][D][switch:037]: 'light_2': Sending state ON
[08:31:14][D][switch:037]: 'light_3': Sending state ON
[08:31:14][D][switch:017]: 'relay_3' Turning OFF.
[08:31:14][D][switch:037]: 'relay_3': Sending state OFF
[08:31:14][D][switch:013]: 'light_3' Turning ON.
[08:31:14][D][main:449]: template.turn_on.sensor==on
[08:31:15][D][switch:017]: 'light_3' Turning OFF.
[08:31:15][D][main:168]: template.turn_off.sensor==on
[08:31:15][D][switch:013]: 'relay_3' Turning ON.
[08:31:15][D][switch:037]: 'relay_3': Sending state ON
[08:31:15][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:15][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:15][D][switch:037]: 'light_2': Sending state OFF
[08:31:15][D][switch:037]: 'light_3': Sending state OFF
[08:31:15][D][switch:017]: 'relay_3' Turning OFF.
[08:31:15][D][switch:037]: 'relay_3': Sending state OFF
[08:31:15][D][switch:017]: 'light_3' Turning OFF.
[08:31:15][D][main:436]: template.turn_off.sensor==off
[08:31:15][D][switch:017]: 'light_3' Turning OFF.
[08:31:15][D][main:436]: template.turn_off.sensor==off
[08:31:15][D][switch:013]: 'light_3' Turning ON.
[08:31:15][D][main:444]: template.turn_on.sensor==off
[08:31:15][D][switch:013]: 'relay_3' Turning ON.
[08:31:15][D][switch:037]: 'relay_3': Sending state ON
[08:31:15][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:15][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:15][D][switch:037]: 'light_2': Sending state ON
[08:31:15][D][switch:037]: 'light_3': Sending state ON
[08:31:15][D][switch:017]: 'relay_3' Turning OFF.
[08:31:15][D][switch:037]: 'relay_3': Sending state OFF
[08:31:16][D][switch:017]: 'light_3' Turning OFF.
[08:31:16][D][main:168]: template.turn_off.sensor==on
[08:31:16][D][switch:013]: 'relay_3' Turning ON.
[08:31:16][D][switch:037]: 'relay_3': Sending state ON
[08:31:16][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:16][D][switch:037]: 'light_3': Sending state OFF
[08:31:16][D][switch:017]: 'light_3' Turning OFF.
[08:31:16][D][main:436]: template.turn_off.sensor==off
[08:31:16][D][switch:017]: 'relay_3' Turning OFF.
[08:31:16][D][switch:037]: 'relay_3': Sending state OFF
[08:31:16][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:16][D][switch:037]: 'light_2': Sending state OFF
[08:31:16][D][switch:013]: 'light_3' Turning ON.
[08:31:16][D][main:444]: template.turn_on.sensor==off
[08:31:16][D][switch:013]: 'relay_3' Turning ON.
[08:31:16][D][switch:037]: 'relay_3': Sending state ON
[08:31:16][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:16][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:16][D][switch:037]: 'light_2': Sending state ON
[08:31:16][D][switch:037]: 'light_3': Sending state ON
[08:31:16][D][switch:017]: 'relay_3' Turning OFF.
INFO lightscontrol-1.local: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for lightscontrol-1.local
WARNING Disconnected from API
INFO lightscontrol-1.local: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Successfully connected to lightscontrol-1.local
[08:31:55][D][switch:017]: 'light_3' Turning OFF.
[08:31:55][D][main:168]: template.turn_off.sensor==on
[08:31:55][D][switch:013]: 'relay_3' Turning ON.
[08:31:55][D][switch:037]: 'relay_3': Sending state ON
[08:31:55][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:55][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:55][D][switch:037]: 'light_2': Sending state OFF
[08:31:55][D][switch:037]: 'light_3': Sending state OFF
[08:31:55][D][switch:017]: 'relay_3' Turning OFF.
[08:31:55][D][switch:037]: 'relay_3': Sending state OFF
[08:31:55][D][switch:017]: 'light_3' Turning OFF.
[08:31:55][D][main:436]: template.turn_off.sensor==off
[08:31:55][D][switch:017]: 'light_3' Turning OFF.
[08:31:55][D][main:436]: template.turn_off.sensor==off
[08:31:56][D][switch:013]: 'light_3' Turning ON.
[08:31:56][D][main:444]: template.turn_on.sensor==off
[08:31:56][D][switch:013]: 'relay_3' Turning ON.
[08:31:56][D][switch:037]: 'relay_3': Sending state ON
[08:31:56][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:56][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:56][D][switch:037]: 'light_2': Sending state ON
[08:31:56][D][switch:037]: 'light_3': Sending state ON
[08:31:56][D][switch:013]: 'light_3' Turning ON.
[08:31:56][D][main:449]: template.turn_on.sensor==on
[08:31:56][D][switch:017]: 'relay_3' Turning OFF.
[08:31:56][D][switch:037]: 'relay_3': Sending state OFF
[08:31:56][D][switch:013]: 'light_3' Turning ON.
[08:31:56][D][main:449]: template.turn_on.sensor==on
[08:31:56][D][switch:017]: 'light_3' Turning OFF.
[08:31:56][D][main:168]: template.turn_off.sensor==on
[08:31:56][D][switch:013]: 'relay_3' Turning ON.
[08:31:56][D][switch:037]: 'relay_3': Sending state ON
[08:31:56][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:56][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:56][D][switch:037]: 'light_2': Sending state OFF
[08:31:56][D][switch:037]: 'light_3': Sending state OFF
[08:31:56][D][switch:017]: 'light_3' Turning OFF.
[08:31:56][D][main:436]: template.turn_off.sensor==off
[08:31:56][D][switch:017]: 'relay_3' Turning OFF.
[08:31:56][D][switch:037]: 'relay_3': Sending state OFF
[08:31:57][D][switch:017]: 'light_3' Turning OFF.
[08:31:57][D][main:436]: template.turn_off.sensor==off
[08:31:57][D][switch:017]: 'light_3' Turning OFF.
[08:31:57][D][main:436]: template.turn_off.sensor==off
[08:31:57][D][switch:013]: 'light_3' Turning ON.
[08:31:57][D][main:444]: template.turn_on.sensor==off
[08:31:57][D][switch:013]: 'relay_3' Turning ON.
[08:31:57][D][switch:037]: 'relay_3': Sending state ON
[08:31:57][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:57][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:57][D][switch:037]: 'light_2': Sending state ON
[08:31:57][D][switch:037]: 'light_3': Sending state ON
[08:31:57][D][switch:013]: 'light_3' Turning ON.
[08:31:57][D][main:449]: template.turn_on.sensor==on
[08:31:57][D][switch:017]: 'relay_3' Turning OFF.
[08:31:57][D][switch:037]: 'relay_3': Sending state OFF
[08:31:57][D][switch:013]: 'light_3' Turning ON.
[08:31:57][D][main:449]: template.turn_on.sensor==on
[08:31:58][D][switch:013]: 'light_3' Turning ON.
[08:31:58][D][main:449]: template.turn_on.sensor==on
[08:31:58][D][switch:017]: 'light_3' Turning OFF.
[08:31:58][D][main:168]: template.turn_off.sensor==on
[08:31:58][D][switch:013]: 'relay_3' Turning ON.
[08:31:58][D][switch:037]: 'relay_3': Sending state ON
[08:31:58][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:58][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:58][D][switch:037]: 'light_2': Sending state OFF
[08:31:58][D][switch:037]: 'light_3': Sending state OFF
[08:31:58][D][switch:017]: 'relay_3' Turning OFF.
[08:31:58][D][switch:037]: 'relay_3': Sending state OFF
[08:31:58][D][switch:017]: 'light_3' Turning OFF.
[08:31:58][D][main:436]: template.turn_off.sensor==off
[08:31:58][D][esp32.preferences:114]: Saving preferences to flash...
[08:31:58][D][switch:013]: 'light_3' Turning ON.
[08:31:58][D][main:444]: template.turn_on.sensor==off
[08:31:58][D][switch:013]: 'relay_3' Turning ON.
[08:31:58][D][switch:037]: 'relay_3': Sending state ON
[08:31:58][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:58][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:58][D][switch:037]: 'light_2': Sending state ON
[08:31:58][D][switch:037]: 'light_3': Sending state ON
[08:31:58][D][switch:017]: 'relay_3' Turning OFF.
[08:31:58][D][switch:037]: 'relay_3': Sending state OFF
[08:31:58][D][switch:013]: 'light_3' Turning ON.
[08:31:58][D][main:449]: template.turn_on.sensor==on
[08:31:59][D][switch:017]: 'light_3' Turning OFF.
[08:31:59][D][main:168]: template.turn_off.sensor==on
[08:31:59][D][switch:013]: 'relay_3' Turning ON.
[08:31:59][D][switch:037]: 'relay_3': Sending state ON
[08:31:59][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:31:59][D][switch:037]: 'light_3': Sending state OFF
[08:31:59][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:31:59][D][switch:037]: 'light_2': Sending state OFF
[08:31:59][D][switch:017]: 'relay_3' Turning OFF.
[08:31:59][D][switch:037]: 'relay_3': Sending state OFF
[08:31:59][D][switch:017]: 'light_3' Turning OFF.
[08:31:59][D][main:436]: template.turn_off.sensor==off
[08:31:59][D][switch:013]: 'light_3' Turning ON.
[08:31:59][D][main:444]: template.turn_on.sensor==off
[08:31:59][D][switch:013]: 'relay_3' Turning ON.
[08:31:59][D][switch:037]: 'relay_3': Sending state ON
[08:31:59][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:31:59][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:31:59][D][switch:037]: 'light_2': Sending state ON
[08:31:59][D][switch:037]: 'light_3': Sending state ON
[08:31:59][D][switch:017]: 'relay_3' Turning OFF.
[08:31:59][D][switch:037]: 'relay_3': Sending state OFF
[08:31:59][D][switch:013]: 'light_3' Turning ON.
[08:31:59][D][main:449]: template.turn_on.sensor==on
[08:32:00][D][switch:017]: 'light_3' Turning OFF.
[08:32:00][D][main:168]: template.turn_off.sensor==on
[08:32:00][D][switch:013]: 'relay_3' Turning ON.
[08:32:00][D][switch:037]: 'relay_3': Sending state ON
[08:32:00][D][binary_sensor:036]: 'sensor_2': Sending state OFF
[08:32:00][D][binary_sensor:036]: 'sensor_3': Sending state OFF
[08:32:00][D][switch:037]: 'light_2': Sending state OFF
[08:32:00][D][switch:037]: 'light_3': Sending state OFF
[08:32:00][D][switch:017]: 'light_3' Turning OFF.
[08:32:00][D][main:436]: template.turn_off.sensor==off
[08:32:00][D][switch:017]: 'relay_3' Turning OFF.
[08:32:00][D][switch:037]: 'relay_3': Sending state OFF
[08:32:00][D][switch:017]: 'light_3' Turning OFF.
[08:32:00][D][main:436]: template.turn_off.sensor==off
[08:32:00][D][switch:013]: 'light_3' Turning ON.
[08:32:00][D][main:444]: template.turn_on.sensor==off
[08:32:00][D][switch:013]: 'relay_3' Turning ON.
[08:32:00][D][switch:037]: 'relay_3': Sending state ON
[08:32:00][D][binary_sensor:036]: 'sensor_2': Sending state ON
[08:32:00][D][binary_sensor:036]: 'sensor_3': Sending state ON
[08:32:00][D][switch:037]: 'light_2': Sending state ON
[08:32:00][D][switch:037]: 'light_3': Sending state ON
[08:32:00][D][switch:013]: 'light_3' Turning ON.
[08:32:00][D][main:449]: template.turn_on.sensor==on
[08:32:00][D][switch:017]: 'relay_3' Turning OFF.
INFO lightscontrol-1.local: Error while reading incoming messages: Error while reading data: [Errno 104] Connection reset by peer
INFO Disconnected from ESPHome API for lightscontrol-1.local
WARNING Disconnected from API
INFO lightscontrol-1.local: Ping Failed: Error while reading data: [Errno 104] Connection reset by peer
INFO Successfully connected to lightscontrol-1.local

Hello,
I have got the same issue.
How did yow solved the problem?

Hello.

After a lot of testing, My guess is that the problem is electrical. When I turn the relays off, even if I have a ULN2003A and a second diode, I still see spikes:

I got two recommendations for this.

  1. I have in the same ground plane the ESP32 and the relays. I split them all the way to the power supply
    image

  2. Add an RC Snubber in my line. Since I did not want to do that, I ended up using a SSR with integrated snubber instead of a normal relay. That reduced the spikes as seen here:

i am waiting for the new boards with the new design, to fully test it out, but my preliminary results are quite good (no resets at all)

Let me know if this is not clear - happy to expand my answer
The full project with the schematics and layouts is here: GitHub - crgarcia12/electronics-homeassistant-lightscontroll

Hellow, did your solution works?
I have the same issue, but my device restarts, even there is no change of relays or something.
Even when it is in stand-by, sometimes it restarts…

I built it one week ago, and it seems to work… but one week testing is not enough I think.
Have you checked your capacitors? Are your schematics/layout open source?

You can take a look at mine for comparison. You can also check it with an oscilloscope to see how it behaves

Hello,
How are the results of your test now?
I don’t now how I’m going to fix it, I guess I will add an RC snubber on my AC entry.
And I’ll will test it for some time.
Now I’m sure, my problem is with the relays, when the relays don’t have to act, there is no problem.

I left it couple of days 24hs in a row ON turning on/off every 2 seconds and It works very well.
I did three things, and I can’t say which is the one that worked:

  1. Changed relays by SSR
  2. Use relays with integrated snubber
  3. Separated GND

I believe that doing 1) and 2) is enough. you can check my design and the parts I am using.
I really don’t understand why does this happens, since I have tried with Diodes, TVS and capacitors (which should do the job in theory) and it did not work… so I am missing something for sure.

I am also using very small (package size) capacitors next to the ESP 3.3. I guess having bigger caps could help

Sometimes it is weird. I have 2 pcb’s, with the first, there are the same relays, en they switch over every minute, and there are no problems, and another the relay is turning on/off more slowly, and there are problems sometimes… I will also try with SSR.