WLED: Invalid response from WLED API in Home Assistant when simply turning on the LED strip
What happened?
Many times when one of my automations in Home Assistant is just simply turning on the LED strip (60 LEDs, no segments, so not really a big thing), the Home Assistant automation fails to do so because it received a Invalid response from WLED API error response from the device.
1 minute later it would just turn on fine as it would normally do without issues.
This started to happen since version 0.15.0 and as some people reported on this Home Assistant issue (https://github.com/home-assistant/core/issues/132284), the issues are gone when you downgrade back to 0.14.4.
To Reproduce Bug
It is hard to reproduce as it seems to be just randomly happening and a few seconds/minutes later there is no issue at all when turning on the device. It also seems to be correctly working when you manually turn on the device in Home Assistant.
It could be that in the automation I let it set a preset and then turn it on which could cause a API timeout if that happens to fast, but then again, it does work a minute later and there are no issues with this on 0.14.4
Expected Behavior
just normally turn on the LED strip without errors or timeouts
Install Method
Binary from WLED.me
What version of WLED?
0.15.0
Which microcontroller/board are you seeing the problem on?
ESP8266
Relevant log/trace output
Anything else?
No response
Code of Conduct
- I agree to follow this project’s Code of Conduct
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 4
- Comments: 20 (5 by maintainers)
Thank you for the log! I’m seeing a
(503, {'error': 3})error, which would imply this is a problem on the WLED side indeed and indicates this is a failure to allocate the JSON buffer, which also explains it’s intermittency. Now to figure out whether there is a bug with releasing the buffer somewhere, or a case of too many things trying to acquire the buffer at the same time…“Need” is a strong word … 😉 Yes, 0.16 attempts to accommodate clients that don’t properly handle HTTP retries.
Arg, I’m just misinterpreting the image of a diff above – I’m used to a line-oriented diff display. The 0.16 code is fine.
So to summarize: a 503 HTTP response (“Service Unavailable”) is WLED telling the client to “come back later”, and no, HA doesn’t respect them and faults instead. The switch to using the new AWS
deferResponse()feature in 0.16 should “correct” this by queuing the request in WLED until it’s ready to be serviced.updated to the latest nightly (0.16.0 alpha). Let’s see if that helps…