KaufHA/kauf-rgb-switch

new esphome update is disconnecting wifi and ap

Opened this issue · 42 comments

new esphome update is disconnecting the switches from wifi and the ap wont connect.. I've updated two switches out of 10 and after the second one I stopped

Is your Wi-Fi network using a hidden SSID? What does your yaml look like? Were you able to get the two back online?

OK for starters I would recommend downgrading to ESPHome 2024.4.2. From there, work on getting all your switches back to that version. In the yaml you can just add @2024.4 to the end of the packages line to point to the 2024.4.2 version of the yaml package.

When you are connected to the AP you can try setting credentials like this in a web browser: http://192.168.4.1/wifisave?ssid=YOUR_SSID&psk=YOUR_PASSWORD. Otherwise, you can also try setting up a Wi-Fi hotspot with credentials initial_ap / asdfasdfasdfasdf and see if the switches connect to that.

I was having lots of these issues. Found one error in the yaml requiring min version 3000.5.0. Copied whole yaml text, changed that, then updated. Now all is well

I bumped the min version way up to prevent people bricking their switches if they tried to update. I went ahead and fixed that change so the default yaml can be compiled now, and reverted the change to the web_server that has been causing so much problems.

@jajelectric - what is the status on your switches? The web page on the switch should work now if you update again.

@jajelectric if you can't visit the page then you probably didn't get the latest update. You need to delete the .esphome/packages directory or wait 24 hours. On the first one, you should be able to OTA the latest update after 24 hours so I'd just wait. For the second one, did you try to set the wifi credentials using the http command instead of using the web page when connected to the AP (http://192.168.4.1/wifisave?ssid=YOUR_SSID&psk=YOUR_PASSWORD)? The other thing you can try is putting up the initial_ap / asdfasdfasdfasdf network and the switch should connect to that and be flashable that way.

@Kebo2r What is its status right now? Is it connected to wifi? Is it working at all? Can you access it at all?

I have install the new update on three of my switches.. just to confirm that its not a connection error on my end and I wasn't able to connect to the web page by the visit button in esphome the first two was a problem from the first update and the last switch was 10min ago and it will not connect to the page but its connected to the network and homeassistant ...so there is still a problem but its not really a problem if u don't use the webpage...
thanks for the help bkaufx your definitely a genius and I love your switches!!! I have 10 and 10 more to go for the whole house... I'll be waiting to update the rest of my switches

I don't know if this will help to get to the problem..
WARNING kauf-rgbsw-63e9f8 @ 192.168.5.116: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for kauf-rgbsw-63e9f8 @ 192.168.5.116
WARNING Disconnected from API
INFO Successfully connected to kauf-rgbsw-63e9f8 @ 192.168.5.116 in 0.007s
INFO Successful handshake with kauf-rgbsw-63e9f8 @ 192.168.5.116 in 2.392s
[21:45:37][D][esp8266.preferences:274]: Saving preferences to flash...
[21:46:20][D][sensor:093]: 'Kauf RGB Sw Uptime': Sending state 98.31800 s with 0 decimals of accuracy
WARNING kauf-rgbsw-63e9f8 @ 192.168.5.116: Connection error occurred: kauf-rgbsw-63e9f8 @ 192.168.5.116: EOF received
INFO Processing unexpected disconnect from ESPHome API for kauf-rgbsw-63e9f8 @ 192.168.5.116
WARNING Disconnected from API
INFO Successfully connected to kauf-rgbsw-63e9f8 @ 192.168.5.116 in 0.009s
WARNING kauf-rgbsw-63e9f8 @ 192.168.5.116: Connection error occurred: [Errno 104] Connection reset by peer
WARNING Can't connect to ESPHome API for kauf-rgbsw-63e9f8 @ 192.168.5.116: Handshake failed: [Errno 104] Connection reset by peer (HandshakeAPIError)
INFO Trying to connect to kauf-rgbsw-63e9f8 @ 192.168.5.116 in the background
INFO Successfully connected to kauf-rgbsw-63e9f8 @ 192.168.5.116 in 0.007s
WARNING kauf-rgbsw-63e9f8 @ 192.168.5.116: Connection error occurred: [Errno 104] Connection reset by peer
INFO Successfully connected to kauf-rgbsw-63e9f8 @ 192.168.5.116 in 0.027s
WARNING kauf-rgbsw-63e9f8 @ 192.168.5.116: Connection error occurred: kauf-rgbsw-63e9f8 @ 192.168.5.116: EOF received
INFO Successfully connected to kauf-rgbsw-63e9f8 @ 192.168.5.116 in 0.011s
WARNING kauf-rgbsw-63e9f8 @ 192.168.5.116: Connection error occurred: [Errno 104] Connection reset by peer

this is the same now for all three switches

I was able to get mine back online as well using the curl method connecting to the switch. Saw the webpage one time and never again. Tried updating again from the ESPHOME dash and it did the same thing that started this which is failing at around 13% on the upload. See below.

INFO Compressed to 371834 bytes
Uploading: [======== ] 13% ERROR Error receiving acknowledge chunk OK: timed out

Oddly enough after that failure the switch is up showing online on the dashboard and the webpage loaded. I kept that page alive just in case and tried loading the switch ip in another tab. Rather than loading the webpage it begins a download of a file "192.168.40.10.download" that never finishes. The original page still works and controls fine and the log works since I haven't closed it. Going to try uploading an older firmware if I can find one. Hope this helps diagnose.

I had the same thing and I hit retry and about the fifth time it finally did it and I too had the web page open prior to updating but it stopped reporting right after the OTA update
I also had the downloads that didn't download anything

I'm learning all of this so very much a newb. Maybe this makes sense to someone but I just managed to get back to firmware 1.32 and still have the same issue with no webpage available but connected via HA. Guess I'll stop here for now until something changes. FWIW

To be cleared not to hijack your thread but this is now happening to all my esphome Kauf devices. I can't reach any of my bulbs webpage either. Has to be the 2024.5.0 or .1 or .2 updates and the updates I did to these devices after that. Although I don't pretend to understand that update interacts with these devices. @bkaufx .. FWIW

ETA: As I sent this one of my bulb pages that ive been trying to load all night just popped up and working fine. No idea what's going on. Haven't changed any network settings. Only changes have been ESPHome and device updates.

I was thinking the web page wasn't important but it is because I have some switches that has the relay on all the time and the push action turns on wifi lights and if for some reason that stops working I have no way of going back in to change it

Another update. The bulb where the webpage was working last night this morning no longer loads and is back showing offline. Still no joy on the switch as well. This has to be a ESPHome issue right? And when we update it rebuilds the error in the devices. I saw on another thread someone said the size of the file increased for their Athom bulb t o where it was too large with the update.

If you add @2024.4 to the end of the packages line in your yaml config it should point back to the yaml for ESPHome 2024.4.2 so you can install that version if you want. The latest updates I just posted yesterday should fix this issue for 2024.5.2 but you either have to delete your .esphome/packages folder or wait 24 hours to get the updates.

e.g.:

packages:
  Kauf.RGBSw: github://KaufHA/kauf-rgb-switch/kauf-rgbs.yaml@2024.4

there has to be something else going on because I did as instructed on one of the switches that wont load the web page and its still not loading the page... i cleared my cache to make sure it wasnt my browser ..substitutions:
name: kauf-rgbsw-1e66df
friendly_name: master_bath_vanity
packages:
Kauf.RGBSw: github://KaufHA/kauf-rgb-switch/kauf-rgbs.yaml@2024.4
esphome:
name: ${name}
name_add_mac_suffix: false
api:
encryption:
key: 4r1+O+hwcKp9UEi6yUN2+hq+hqvvzZo1yyZ/IgxyHyc=

wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
this is my setup
it connects way better to the switch.. handshake and all... with the other updates it gives me a timeout error and a handshake error
even the new 2024.5.2 doesnt work as of yet

well I just checked the logs and its saying different

INFO ESPHome 2024.5.2
INFO Reading configuration /config/esphome/kauf-rgbsw-1e66df.yaml...
INFO Starting log output from 192.168.5.84 using esphome API
INFO Successfully connected to kauf-rgbsw-1e66df @ 192.168.5.84 in 0.016s
WARNING kauf-rgbsw-1e66df @ 192.168.5.84: Connection error occurred: [Errno 104] Connection reset by peer
WARNING Can't connect to ESPHome API for kauf-rgbsw-1e66df @ 192.168.5.84: Handshake failed: [Errno 104] Connection reset by peer (HandshakeAPIError)
INFO Trying to connect to kauf-rgbsw-1e66df @ 192.168.5.84 in the background
INFO Successfully connected to kauf-rgbsw-1e66df @ 192.168.5.84 in 0.011s
WARNING kauf-rgbsw-1e66df @ 192.168.5.84: Connection error occurred: [Errno 104] Connection reset by peer
INFO Successfully connected to kauf-rgbsw-1e66df @ 192.168.5.84 in 0.006s
WARNING kauf-rgbsw-1e66df @ 192.168.5.84: Connection error occurred: [Errno 104] Connection reset by peer
INFO Successfully connected to kauf-rgbsw-1e66df @ 192.168.5.84 in 0.005s
WARNING kauf-rgbsw-1e66df @ 192.168.5.84: Connection error occurred: kauf-rgb
and instead of 2024.4 it is showing 2024.5.2.. I dont know why it would.. I did the @2024.4 after packages

So I finally got my switch back online. Controllable in HA and shows online on dash. Logs viewable etc. However I was a bee to get to the webpage for a while then without any changes the webpage stopped working and now is back to just starting a download of some kind when I try to navigate to it. I've reinstalled multiple times etc and it's been well more than 24hours. Any other ideas? Thanks!

Now my PLF12 plug is doing the same. Online in dash, unavailable in HA, and webpage loads a file download of some kind..

In the interest of providing @bkaufx as much info as possible another update. It seems like the switch at least will load the webpage randomly every so often when tried at the .local domain. Once it works once thought it doesn't work again for a long while. The ip address method seems to not work at any time. Similar on the plug.

Here's one entry that loaded in the log when it did load:

2:10:32 [E] [json:041]
Could not allocate memory for JSON document! Requested 496 bytes, largest free heap block: 496 bytes

I loaded the minimal firmware and having more success but its still very sporadic and hit or miss. I did catch this earlier one of the times it managed to load: safe mode?

Captive Portal:
14:00:10 [C] [web_server:173]
Web Server:
14:00:10 [C] [web_server:174]
Address: kaufswitch.local:80
14:00:10 [C] [mdns:115]
mDNS:
14:00:10 [C] [mdns:116]
Hostname: kaufswitch
14:00:11 [C] [ota:096]
Over-The-Air Updates:
14:00:11 [C] [ota:097]
Address: kaufswitch.local:8266
14:00:11 [C] [ota:103]
OTA version: 2.
14:00:11 [W] [ota:106]
Last Boot was an unhandled reset, will proceed to safe mode in 7 restarts
14:00:11 [C] [api:139]
API Server:
14:00:11 [C] [api:140]
Address: kaufswitch.local:6053
14:00:11 [C] [api:144]
Using noise encryption: NO
14:00:11 [C] [wifi_info:009]
WifiInfo IPAddress 'KaufSwitch IP Address'
14:00:11 [C] [homeassistant.text_sensor:023]
Homeassistant Text Sensor 'hass_small_light_state'
14:00:13 [C] [homeassistant.text_sensor:024]
Entity ID: 'no.ne'
14:00:13 [C] [homeassistant.text_sensor:023]
Homeassistant Text Sensor 'hass_big_light_state'
14:00:13 [C] [homeassistant.text_sensor:024]
Entity ID: 'no.ne'
14:00:37 [D] [api:102]
Accepted 192.168.40.189
14:00:37 [D] [api.connection:1321]
Home Assistant 2024.5.4 (192.168.40.189): Connected successfully

Looks to be a memory issue for sure. Just watched a switch go from unavailable to available, immediately loaded the web page and caught this again:

Could not allocate memory for JSON document! Requested 504 bytes, largest free heap block: 504 bytes
14:09:55 [E] [json:041]
Could not allocate memory for JSON document! Requested 504 bytes, largest free heap block: 504 bytes
14:09:55 [E] [json:041]
Could not allocate memory for JSON document! Requested 504 bytes, largest free heap block: 504 bytes
14:09:55 [E] [json:041]
Could not allocate memory for JSON document! Requested 504 bytes, largest free heap block: 504 bytes
14:09:55 [E] [json:041]
Could not allocate memory for JSON document! Requested 504 bytes, largest free heap block: 504 bytes
14:09:56
14:10:23 [D] [esp8266.preferences:238]
Saving preferences to flash...
14:10:23 [W] [component:237]
Component preferences took a long time for an operation (68 ms).
14:10:23 [W] [component:238]
Components should block for at most 30 ms.
14:10:33 [D] [sensor:093]
'KaufSwitch Uptime': Sending state 50.81200 s with 0 decimals of accuracy

It appears maybe a memory leak? is filling up and then causing the switch to go offline. then maybe a restart dumps it and allows it to connect for a little while? No idea if that makes sense but FWIW

This is a different issue to the one I figured out and fixed. This is the page not loading at all. With the first problem, the page would load but it couldn't connect to the events server. I'm seeing the same thing here but it works fine when I put the same firmware on a d1 mini so I can't see serial logs. I'm probably going to have to wire onto an actual switch to see what is going on in more detail. Probably won't get to it until this weekend or maybe even next weekend.

Edit: The JSON allocation has always been in the logs, so while it might be related it doesn't by itself tell me much.

If you are currently using the default package you can change the packages line to the following to use minimal instead of the normal version.

packages:
  Kauf.RGBSw: github://KaufHA/kauf-rgb-switch/config/kauf-rgbs-minimal.yaml

That’s been my problem the whole time… it’s never been able to load the page or even do logs..well not the whole problem in the beginning the switches went off line and I believe you have fixed that for sure cause all of mine are in fact still connected.. Thanks

On Thu, May 23, 2024 at 12:32 PM Brian Kaufman @.> wrote: This is a different issue to the one I figured out and fixed. This is the page not loading at all. With the first problem, the page would load but it couldn't connect to the events server. I'm seeing the same thing here but it works fine when I put the same firmware on a d1 mini so I can't see serial logs. I'm probably going to have to wire onto an actual switch to see what is going on in more detail. Probably won't get to it until this weekend or maybe even next weekend. — Reply to this email directly, view it on GitHub <#17 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYF464OARYILEA6NTGOE7L3ZDYKYHAVCNFSM6AAAAABH5TQIBOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRXGU4TANJSHE . You are receiving this because you were mentioned.Message ID: @.>

having the same issue with the switches and plugs resetting. the webpage can be disabled using the following setting in esphome:

web_server:
!remove

this seems to stabilize the switches and plugs until a fix is in place at least for me

I just recently bought the switches and I am also experiencing the disconnects.
Leaving the computer pinging the switch I get frequent timeouts. I keep seeing these in the logs if any of these make sense...

I've noticed that sometimes, when the timeouts happen, the switch will default to a light blue color and the small light will blink red for a few seconds.

I have the 4m model. How would I set the minimal yaml onto those?

Any way, when it works this is fantastic. Extremely low latency and fast changing leds.

This is always showing up in the logs if helpful.

21:00:50	[E]	[json:041]	
Could not allocate memory for JSON document! Requested 432 bytes, largest free heap block: 432 bytes
21:00:50	[E]	[json:041]	
Could not allocate memory for JSON document! Requested 296 bytes, largest free heap block: 296 bytes
21:00:50	[E]	[json:041]	
Could not allocate memory for JSON document! Requested 392 bytes, largest free heap block: 392 bytes
21:00:50	[E]	[json:041]	
Could not allocate memory for JSON document! Requested 328 bytes, largest free heap block: 328 bytes