You don’t need the web server for OTA updates.
Just Wifi, API, OTA.
I usually disable it unless I have some need. Give it a go.
Your devices showing as offline doesn’t sound good and could be WiFi/API connectivity issues.
You don’t need the web server for OTA updates.
Just Wifi, API, OTA.
I usually disable it unless I have some need. Give it a go.
Your devices showing as offline doesn’t sound good and could be WiFi/API connectivity issues.
OK I have figured out why they showed up as offline and it was because I did not assign the docker container to the correct network.
I have also tried to disable the web server and reduced the polling time, but unfortunately it did not change anything at all.
Seems like I am going back to Tasmota, since ESPHome unfortunately is not stable enough…
ESPHome is very stable. It is something about your set-up.
If it is unstable in a weird setup(which I want to disagree, since I am following the tutorial by someone who seems to know what should be done: Calibrating an ESPHome flashed power plug » Frenck.dev), it is still unstable…
I’m not very good with networking or advanced HA / ESPHome set-ups so am unlikley to be of much help.
Good luck with finding the best solution that works for you.
@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.
Regarding “Frenck”: That is exactly what I wanted to say in a very sarcastic undertone
I can no longer test it, because I have switched back to Tasmota, which runs fine under any conditions.
ESPHome has been configured to ignore connection problems to WiFi and HA and still reboots. Unfortunately I did not find any way to maybe gather some logs as to why it reboots.
Additionally one of my plugs is no longer reachable via the Network (and also does not create the fallback WiFi Network), so I will have to open it up and try to flash it again. We’ll see, maybe I will run that one with ESPHome and be able to figure out why it is randomly rebooting.
He’s not one of the main ESPHome devs though.
But yes, safe to say he has a very high level of home automation knowledge and generally knows what he’s doing!
Another resource that might be of help (section on wifi-problems):
plugs randomly switching on and off is a sign of them dying.
soon they won’t even turn on at all or connect.
i have 5 single plugs and one 4-plug-device that died this way.
me and a friend suspect the esp8266 inside are brown-outing and that they could be resurrected by adding a capacitor to circumvent this.
Hi,
thank you for providing your code! I was searching for the (very basic) solution to turn a device on after a reboot and that was exactly what i was looking for. But, i am a little bit confused that you seem to have included two ways of doing that (the restore_mode: ALWAYS_ON setting and the on-boot automation). I assume thats intentional, but i don’t understand it - why both? What am i missing here?
I believe the two are redundant so you might just have to test each one individually to see which one works best for you. I was trying to prevent the outlet from switching off during firmware update but it still does even though it appears to switch back on very quickly (I hear what sounds like a single click for the on-off-on).
The only difference I think there may be between the two methods is when it is executed. The one you quoted is set to priority 600 (see priority levels here: ESPHome Core Configuration — ESPHome) while the other method may happen a fraction of a second later… which likely makes absolutely no difference.
I am just a tinkerer, not an expert
Awesome, thanks! I’ll try both of them.
[kamtschatka] : I am really curious - Have you got any solution for this? I am sure this is not at all an easy solution as it is not experienced by Many. Because of this issue I lost a big project (Had to quit) - as couldn’t solve the erratic behavior of the Switch. I know it just cant be resolved only through config but may also need Hardware modification like adding Physical Resistors with your Binary Switch GPIO as a hardware Pull-up setup. It may improve the experience but still I personally couldn’t get through this problem. I had to leave the project with a shame. I am ready to discuss this with people provided - they have experienced this or resolved such issues. An Assumption or just throwing a suggestion will not work .
Do let me know if you have figured out the issues by yourself - it will be helpful for me.
No, I have not tried any further. I switched back to Tasmota and haven’t had any issue since. So I don’t think it is a hardware issue, I think it is an issue with ESPHome.
If the issue you are trying to resolve is the relay toggling when updating firmware, it has been solved.
Use the YAML from this post:
The solution to the issue lies with this instruction
early_pin_init: false #This prevents the on-off-on of the relay upon firmware upload
I am having this happen on a couple of esphome devices. I have a relay based one that randomly turns itself off. Another is a PWM driven LED that randomly turns off. Uptime is reset to 0 each time so appear to reboot.
Hello @tomhaslett and welcome to the community!
I’m sure the post from @arufell (just before yours) has all the hints you need to work’a’round your troubles. Essentially the early_pin_init
combined with your restore
of choice should be everything you need
Feel free to leave your working yaml
here for other lost souls
So your problem is randomly rebooting esp or esp switching randomly relay off??
ESPHome reboots on purpose when something is not going right, e.g. wifi connection cannot be made or api connection is lost or mqtt connection is lost. So if you are facing this problem you’ll need to explicitly set the
reboot_timeout
option to0s
on the components being used.