@kamtschatka I concur with @Mahko_Mahko on all the suggestions he gave you and the fact that ESPHome is very stable. I have 9 Sonoff s31 outlets running very similar YAML to what you posted. I am sharing it in case you see something you want to test:
I have mine split into 2 files so that I can keep the per device file as small as possible, and keep all the common code in the other file. This makes it easier to make the same update to all outlets.
substitutions:
devicename: s31-outlet-1
devicename_no_dashes: s31_outlet_1
friendly_devicename: "Office Equipment Outlet"
device_description: "Office Equipment Outlet"
voltage_cal: "0.5"
restore_mode_setting: ALWAYS_ON
#restore_mode: Control how the relay attempts to restore state on bootup.
#RESTORE_DEFAULT_OFF - Attempt to restore state and default to OFF if not possible to restore.
#RESTORE_DEFAULT_ON - Attempt to restore state and default to ON if not possible to restore.
#RESTORE_INVERTED_DEFAULT_OFF - Attempt to restore state inverted from the previous state and default to OFF.
#RESTORE_INVERTED_DEFAULT_ON - Attempt to restore state inverted from the previous state and default to ON.
#ALWAYS_OFF - Always initialize the pin as OFF on bootup.
#ALWAYS_ON - Always initialize the pin as ON on bootup.
# Interval of how often the wifi info is updated
update_interval_wifi: "60s"
# Basic Config
esphome:
name: ${devicename}
comment: ${device_description}
platform: ESP8266
board: esp01_1m
on_boot:
priority: 600.0
then:
- switch.turn_on: relay
<<: !include s31-outlet-template.yaml
wifi:
ssid: !secret iot_wifi_ssid
password: !secret iot_wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "${devicename} Hotspot"
password: !secret iot_wifi_password
#Faster than DHCP. Also use if can't reach because of name change
# manual_ip:
# static_ip: 192.168.3.196
# gateway: 192.168.3.1
# subnet: 255.255.255.0
# dns1: 192.168.1.25
# dns2: 192.168.1.26
#Manually override what address to use to connect to the ESP.
#Defaults to auto-generated value. Example, if you have changed your
#static IP and want to flash OTA to the previously configured IP address.
# use_address: 192.168.3.171
logger:
baud_rate: 0 # (UART logging interferes with cse7766)
# Remove this line if you're not using Home Assistsant or your switch will restart every now and again
api:
ota:
web_server:
port: 80
include_internal: true
# Sync time with Home Assistant
time:
- platform: homeassistant
id: ha_time
# Device Specific Config
uart:
rx_pin: RX
baud_rate: 4800
text_sensor:
- platform: wifi_info
ip_address:
name: "${friendly_devicename}: IP"
icon: "mdi:ip-outline"
ssid:
name: "${friendly_devicename}: SSID"
icon: "mdi:wifi-settings"
bssid:
name: "${friendly_devicename}: BSSID"
icon: "mdi:wifi-settings"
mac_address:
name: "${friendly_devicename}: MAC"
icon: "mdi:network-outline"
scan_results:
name: "${friendly_devicename}: Wifi Scan"
icon: "mdi:wifi-refresh"
disabled_by_default: true
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "${friendly_devicename}: Button"
on_press:
- switch.toggle: relay
- platform: status
name: "${friendly_devicename}: Status"
sensor:
- platform: wifi_signal
name: "${friendly_devicename}: WiFi Signal"
update_interval: ${update_interval_wifi}
- platform: cse7766
current:
name: "${friendly_devicename}: Current"
state_class: measurement
device_class: current
unit_of_measurement: A
accuracy_decimals: 1
voltage:
name: "${friendly_devicename}: Voltage"
state_class: measurement
device_class: voltage
unit_of_measurement: V
accuracy_decimals: 1
filters:
- offset: ${voltage_cal}
power:
name: "${friendly_devicename}: Power"
id: "${devicename_no_dashes}_power"
state_class: measurement
device_class: power
unit_of_measurement: W
accuracy_decimals: 1
- platform: total_daily_energy
name: "${friendly_devicename}: Daily Energy"
power_id: "${devicename_no_dashes}_power"
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
state_class: total_increasing
device_class: energy
# 3 shows each W consumed, 2 every 10W, 1 every 100W
accuracy_decimals: 1
switch:
- platform: gpio
name: "${friendly_devicename}"
icon: "mdi:power-socket-us"
pin: GPIO12
id: relay
restore_mode: ${restore_mode_setting}
status_led:
pin: GPIO13
You surely know this but updating the devices, and bad connectivity to WIFI or HA itself can trigger the device to reboot as it tries to re-establish connection. As you found you can disable that but it should not be necessary…
In the two examples you gave, a momentary reboot is not detrimental to your freezer as the power is restored after the reboot (assuming it isn’t constantly looping into a reboot as that may eventually damage your freezer) but I can see how interrupting your 3D printer would be annoying… Anyway, I am pretty sure it is NOT ESPHome’s issue as my 9 outlets are rock solid, as the other dozen or so ESPHome devices I made.
One thing that I would suggest you look at is your WIFI setup. First the obvious… ensure the signal is actually good where the ESPs are located (see signal level reported by the ESP) and also check if the AP / Router receives a strong signal back.
In my case I have 5 APs around the house so I generally do not have signal issues. What I did have issues with when connecting IoT devices were “fancy” WIFI settings that were mostly meant for high performance clients. I created an IoT only SSID and turned everything off to keep it as compatible as possible.
Also, if you have any above typical settings on your network (VLAN, routing rules, etc.) you have to ensure that the ESPHome devices can reach HA. I have my IoT devices on a different VLAN than HA but I ensured there were no barriers to them reaching each other.
I would also try barebone YAML on your outlets to see if something in the code is causing it to crash.
Are you at the device’s memory limit?
These ar ethe logs for one of the outlets I am not using:
INFO Reading configuration /config/esphome/s31-outlet-8.yaml...
INFO Detected timezone 'America/Chicago'
INFO Generating C++ source...
INFO Compiling app...
Processing s31-outlet-8 (board: esp01_1m; framework: arduino; platform: platformio/espressif8266 @ 3.2.0)
--------------------------------------------------------------------------------
HARDWARE: ESP8266 80MHz, 80KB RAM, 1MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- ESPAsyncTCP-esphome @ 1.2.3
|-- ESPAsyncWebServer-esphome @ 2.1.0
| |-- ESPAsyncTCP-esphome @ 1.2.3
| |-- Hash @ 1.0
| |-- ESP8266WiFi @ 1.0
|-- ESP8266WiFi @ 1.0
|-- ESP8266mDNS @ 1.2
|-- ArduinoJson @ 6.18.5
RAM: [==== ] 41.9% (used 34308 bytes from 81920 bytes)
Flash: [==== ] 44.0% (used 450101 bytes from 1023984 bytes)
========================= [SUCCESS] Took 1.69 seconds =========================
INFO Successfully compiled program.
INFO Resolving IP address of s31-outlet-8.local
INFO -> 192.168.3.177
INFO Uploading /data/s31-outlet-8/.pioenvs/s31-outlet-8/firmware.bin (454256 bytes)
INFO Compressed to 311534 bytes
Uploading: [============================================================] 100% Done...
INFO Waiting for result...
INFO OTA successful
INFO Successfully uploaded program.
INFO Starting log output from s31-outlet-8.local using esphome API
INFO Successfully connected to s31-outlet-8.local
[09:48:29][I][app:102]: ESPHome version 2022.11.5 compiled on Dec 5 2022, 19:58:11
[09:48:29][C][status_led:019]: Status LED:
[09:48:29][C][status_led:020]: Pin: GPIO13
[09:48:29][C][wifi:504]: WiFi:
[09:48:29][C][wifi:362]: Local MAC: 8C:AA:B5:66:4E:1F
[09:48:29][C][wifi:363]: SSID: [redacted]
[09:48:29][C][wifi:364]: IP Address: 192.168.3.177
[09:48:29][C][wifi:365]: BSSID: [redacted]
[09:48:29][C][wifi:367]: Hostname: 's31-outlet-8'
[09:48:29][C][wifi:369]: Signal strength: -49 dB ▂▄▆█
[09:48:29][C][wifi:373]: Channel: 11
[09:48:29][C][wifi:374]: Subnet: 255.255.255.0
[09:48:29][C][wifi:375]: Gateway: 192.168.3.1
[09:48:29][C][wifi:376]: DNS1: 192.168.1.25
[09:48:29][C][wifi:377]: DNS2: 192.168.1.26
[09:48:29][C][logger:293]: Logger:
[09:48:29][C][logger:294]: Level: DEBUG
[09:48:29][C][logger:295]: Log Baud Rate: 0
[09:48:29][C][logger:296]: Hardware UART: UART0
[09:48:29][C][uart.arduino_esp8266:102]: UART Bus:
[09:48:29][C][uart.arduino_esp8266:104]: RX Pin: GPIO3
[09:48:29][C][uart.arduino_esp8266:106]: RX Buffer Size: 256
[09:48:29][C][uart.arduino_esp8266:108]: Baud Rate: 4800 baud
[09:48:29][C][uart.arduino_esp8266:109]: Data Bits: 8
[09:48:29][C][uart.arduino_esp8266:110]: Parity: NONE
[09:48:29][C][uart.arduino_esp8266:111]: Stop bits: 1
[09:48:29][C][uart.arduino_esp8266:113]: Using hardware serial interface.
[09:48:29][C][switch.gpio:050]: GPIO Switch 'Spare Outlet 3'
[09:48:29][C][switch.gpio:050]: Icon: 'mdi:power-socket-us'
[09:48:29][C][switch.gpio:051]: Pin: GPIO12
[09:48:29][C][switch.gpio:073]: Restore Mode: Always ON
[09:48:29][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Spare Outlet 3: Button'
[09:48:29][C][gpio.binary_sensor:016]: Pin: GPIO0
[09:48:29][C][homeassistant.time:010]: Home Assistant Time:
[09:48:29][C][homeassistant.time:011]: Timezone: 'CST6CDT,M3.2.0,M11.1.0'
[09:48:29][C][wifi_info:013]: WifiInfo Mac Address 'Spare Outlet 3: MAC'
[09:48:29][C][wifi_info:013]: Icon: 'mdi:network-outline'
[09:48:29][C][status:034]: Status Binary Sensor 'Spare Outlet 3: Status'
[09:48:29][C][status:034]: Device Class: 'connectivity'
[09:48:29][C][cse7766:196]: CSE7766:
[09:48:29][C][cse7766:197]: Update Interval: 60.0s
[09:48:29][C][cse7766:198]: Voltage 'Spare Outlet 3: Voltage'
[09:48:29][C][cse7766:198]: Device Class: 'voltage'
[09:48:29][C][cse7766:198]: State Class: 'measurement'
[09:48:29][C][cse7766:198]: Unit of Measurement: 'V'
[09:48:29][C][cse7766:198]: Accuracy Decimals: 1
[09:48:29][C][cse7766:199]: Current 'Spare Outlet 3: Current'
[09:48:29][C][cse7766:199]: Device Class: 'current'
[09:48:29][C][cse7766:199]: State Class: 'measurement'
[09:48:29][C][cse7766:199]: Unit of Measurement: 'A'
[09:48:29][C][cse7766:199]: Accuracy Decimals: 1
[09:48:29][C][cse7766:200]: Power 'Spare Outlet 3: Power'
[09:48:29][C][cse7766:200]: Device Class: 'power'
[09:48:29][C][cse7766:200]: State Class: 'measurement'
[09:48:29][C][cse7766:200]: Unit of Measurement: 'W'
[09:48:29][C][cse7766:200]: Accuracy Decimals: 1
[09:48:29][C][total_daily_energy:023]: Total Daily Energy 'Spare Outlet 3: Daily Energy'
[09:48:29][C][total_daily_energy:023]: Device Class: 'energy'
[09:48:29][C][total_daily_energy:023]: State Class: 'total_increasing'
[09:48:29][C][total_daily_energy:023]: Unit of Measurement: 'kWh'
[09:48:29][C][total_daily_energy:023]: Accuracy Decimals: 1
[09:48:29][C][web_server:125]: Web Server:
[09:48:29][C][web_server:126]: Address: s31-outlet-8.local:80
[09:48:29][C][mdns:103]: mDNS:
[09:48:29][C][mdns:104]: Hostname: s31-outlet-8
[09:48:29][C][ota:093]: Over-The-Air Updates:
[09:48:29][C][ota:094]: Address: s31-outlet-8.local:8266
[09:48:29][C][api:138]: API Server:
[09:48:29][C][api:139]: Address: s31-outlet-8.local:6053
[09:48:29][C][api:143]: Using noise encryption: NO
[09:48:29][C][wifi_info:009]: WifiInfo IPAddress 'Spare Outlet 3: IP'
[09:48:29][C][wifi_info:009]: Icon: 'mdi:ip-outline'
[09:48:29][C][wifi_info:011]: WifiInfo SSID 'Spare Outlet 3: SSID'
[09:48:29][C][wifi_info:011]: Icon: 'mdi:wifi-settings'
[09:48:29][C][wifi_info:012]: WifiInfo BSSID 'Spare Outlet 3: BSSID'
[09:48:29][C][wifi_info:012]: Icon: 'mdi:wifi-settings'
[09:48:29][C][wifi_info:010]: WifiInfo Scan Results 'Spare Outlet 3: Wifi Scan'
[09:48:29][C][wifi_info:010]: Icon: 'mdi:wifi-refresh'
[09:48:29][C][wifi_signal.sensor:009]: WiFi Signal 'Spare Outlet 3: WiFi Signal'
[09:48:29][C][wifi_signal.sensor:009]: Device Class: 'signal_strength'
[09:48:29][C][wifi_signal.sensor:009]: State Class: 'measurement'
[09:48:29][C][wifi_signal.sensor:009]: Unit of Measurement: 'dBm'
[09:48:29][C][wifi_signal.sensor:009]: Accuracy Decimals: 0
[09:48:29][D][api:102]: Accepted 192.168.1.41
[09:48:29][D][api.connection:917]: Home Assistant 2022.12.0 (192.168.1.41): Connected successfully
[09:48:29][D][time:044]: Synchronized time: 2022-12-08 09:48:29
[09:48:57][D][sensor:126]: 'Spare Outlet 3: WiFi Signal': Sending state -48.00000 dBm with 0 decimals of accuracy
[09:49:18][D][sensor:126]: 'Spare Outlet 3: Voltage': Sending state 123.38359 V with 1 decimals of accuracy
[09:49:18][D][sensor:126]: 'Spare Outlet 3: Current': Sending state 0.00000 A with 1 decimals of accuracy
[09:49:18][D][sensor:126]: 'Spare Outlet 3: Power': Sending state 0.00000 W with 1 decimals of accuracy
[09:49:18][D][sensor:126]: 'Spare Outlet 3: Daily Energy': Sending state 0.00000 kWh with 1 decimals of accuracy
[09:49:57][D][sensor:126]: 'Spare Outlet 3: WiFi Signal': Sending state -47.00000 dBm with 0 decimals of accuracy
[09:50:18][D][sensor:126]: 'Spare Outlet 3: Voltage': Sending state 123.31480 V with 1 decimals of accuracy
[09:50:18][D][sensor:126]: 'Spare Outlet 3: Current': Sending state 0.00000 A with 1 decimals of accuracy
[09:50:18][D][sensor:126]: 'Spare Outlet 3: Power': Sending state 0.00000 W with 1 decimals of accuracy
[09:50:18][D][sensor:126]: 'Spare Outlet 3: Daily Energy': Sending state 0.00000 kWh with 1 decimals of accuracy
[09:50:57][D][sensor:126]: 'Spare Outlet 3: WiFi Signal': Sending state -49.00000 dBm with 0 decimals of accuracy
[09:51:18][D][sensor:126]: 'Spare Outlet 3: Voltage': Sending state 123.15218 V with 1 decimals of accuracy
[09:51:18][D][sensor:126]: 'Spare Outlet 3: Current': Sending state 0.00000 A with 1 decimals of accuracy
[09:51:18][D][sensor:126]: 'Spare Outlet 3: Power': Sending state 0.00000 W with 1 decimals of accuracy
[09:51:18][D][sensor:126]: 'Spare Outlet 3: Daily Energy': Sending state 0.00000 kWh with 1 decimals of accuracy
[09:51:57][D][sensor:126]: 'Spare Outlet 3: WiFi Signal': Sending state -50.00000 dBm with 0 decimals of accuracy
[09:52:18][D][sensor:126]: 'Spare Outlet 3: Voltage': Sending state 123.28909 V with 1 decimals of accuracy
[09:52:18][D][sensor:126]: 'Spare Outlet 3: Current': Sending state 0.00000 A with 1 decimals of accuracy
[09:52:18][D][sensor:126]: 'Spare Outlet 3: Power': Sending state 0.00000 W with 1 decimals of accuracy
[09:52:18][D][sensor:126]: 'Spare Outlet 3: Daily Energy': Sending state 0.00000 kWh with 1 decimals of accuracy
[09:52:57][D][sensor:126]: 'Spare Outlet 3: WiFi Signal': Sending state -51.00000 dBm with 0 decimals of accuracy
[09:53:18][D][sensor:126]: 'Spare Outlet 3: Voltage': Sending state 123.25486 V with 1 decimals of accuracy
[09:53:18][D][sensor:126]: 'Spare Outlet 3: Current': Sending state 0.00000 A with 1 decimals of accuracy
[09:53:18][D][sensor:126]: 'Spare Outlet 3: Power': Sending state 0.00000 W with 1 decimals of accuracy
[09:53:18][D][sensor:126]: 'Spare Outlet 3: Daily Energy': Sending state 0.00000 kWh with 1 decimals of accuracy
[09:53:18][I][ota:113]: Boot seems successful, resetting boot loop counter.
[09:53:57][D][sensor:126]: 'Spare Outlet 3: WiFi Signal': Sending state -48.00000 dBm with 0 decimals of accuracy
[09:54:18][D][sensor:126]: 'Spare Outlet 3: Voltage': Sending state 123.37368 V with 1 decimals of accuracy
[09:54:18][D][sensor:126]: 'Spare Outlet 3: Current': Sending state 0.00000 A with 1 decimals of accuracy
[09:54:18][D][sensor:126]: 'Spare Outlet 3: Power': Sending state 0.00000 W with 1 decimals of accuracy
[09:54:18][D][sensor:126]: 'Spare Outlet 3: Daily Energy': Sending state 0.00000 kWh with 1 decimals of accuracy
I would compare them with yours.
Lol… BTW, “Frenck” is THE Frenck He is the main developer of HA… so he definitely knows what he is talking about.