Can't reload (nor reinstall) a wled integration that was working

I have 3 wled devices.
I “configured” their corresponding integrations and they were fine.
I realized I had not set the name of one of them from the default “wled” so all the entity names were wrong. So I changed the name in wled and then tried to reload the corresponding integration for that device. It gave errors for all the entities. So I removed the integration and and restarted the device and then tried to “configure” it again and now it can’t. Pops “unknown error” The error message is not helpful. The log is below. Everything is current, hasso, core and supervisor.

I restarted the core, restarted hassos, restarted the device nothing seems to clear the issue. I even removed one of the other wled integrations and configured it again, no problem.

It’s only related to this one device and it’s all based on the mac address so I can’t “spoof” ha into thinking it’s a new device. Seems like some “crud” ha ha has been left in the database. Can one directly inspect the database?

Suggestions on what to try next…thx

2021-12-11 15:39:44 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 220, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/wled/config_flow.py", line 66, in async_step_zeroconf_confirm
    return await self._handle_config_flow(user_input)
  File "/usr/src/homeassistant/homeassistant/components/wled/config_flow.py", line 91, in _handle_config_flow
    device = await wled.update()
  File "/usr/local/lib/python3.9/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/wled/wled.py", line 241, in update
    presets = await self.request("/presets.json")
  File "/usr/local/lib/python3.9/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/wled/wled.py", line 202, in request
    response_data = await response.json()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1119, in json
    return loads(stripped.decode(encoding))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 72: invalid start byte

Yes. The files you are looking for are config/.storage/core.config_entries and core.device_registry and core.entity_registry

Be careful. This has the potential to make things much worse. Either make a backup or copy the whole .storage folder elsewhere off your system.

Another method is to copy the file and work on that one, rename the original to core.config_entries.old

That way if you mess up all you have to do is delete your new file and remove the .old extension from the original file.

You will need to restart Home Assistant for any changes to take effect.

@tom_l So you think it really is an issue in database?

If so then these files are sql (ilte?) files or nosql? I mean what tool do I use to inspect/change them.

What entries should I be looking to remove/modify?

I can answer my own question in part. They are plain text files with json in them so I know how to edit them.

I have looked in all three and the only reference to the device in question is an entry in the deleted devices array of core.device_registry. I deleted that and restarted core and the error remains.

Now what can I try? Opening the home-assistant_v2.db file which I read is sqlite.

How can one completely scrub and reload a built in integration like wled. Would that be advised?

Here is the full log again

this seems to be the error. Is this a bug? with whom, where do I submit an issue for wled integration
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 72: invalid start byte

 ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/wled/wled.py", line 241, in update
    presets = await self.request("/presets.json")
  File "/usr/local/lib/python3.9/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/wled/wled.py", line 202, in request
    response_data = await response.json()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1119, in json
    return loads(stripped.decode(encoding))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 72: invalid start byte
2021-12-12 08:36:12 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/wled/config_flow.py", line 39, in async_step_user
    return await self._handle_config_flow(user_input)
  File "/usr/src/homeassistant/homeassistant/components/wled/config_flow.py", line 91, in _handle_config_flow
    device = await wled.update()
  File "/usr/local/lib/python3.9/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/wled/wled.py", line 241, in update
    presets = await self.request("/presets.json")
  File "/usr/local/lib/python3.9/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/wled/wled.py", line 202, in request
    response_data = await response.json()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1119, in json
    return loads(stripped.decode(encoding))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 72: invalid start byte
2021-12-12 08:36:13 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/usr/src/homeassistant/homeassistant/components/wled/config_flow.py", line 39, in async_step_user
    return await self._handle_config_flow(user_input)
  File "/usr/src/homeassistant/homeassistant/components/wled/config_flow.py", line 91, in _handle_config_flow
    device = await wled.update()
  File "/usr/local/lib/python3.9/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/wled/wled.py", line 241, in update
    presets = await self.request("/presets.json")
  File "/usr/local/lib/python3.9/site-packages/backoff/_async.py", line 133, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/wled/wled.py", line 202, in request
    response_data = await response.json()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1119, in json
    return loads(stripped.decode(encoding))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 72: invalid start byte

looks like it was a corrupted presets.json within the wled firmware (nothing to do with HA or the integration) once I imported the presets from another working device the errors went away…

On occasion I’ve had issues with corrruped json settings in wled so not too surprising. This explains why after setting up a new device but importing that same preset.json file the same errors occur.

Would be nice if the integration actaully caught that error and provided a better message or simply continued to load the intgetration and just disabled the bad entity (likely the presets or playlist entity)

4 Likes

I just experianced this exact issue. In my case it was one character (ÿ instead of i)…

{
  "0": {},
  "1": {
    "n": "Halloween",
    "on": true,
    "brÿ": 255,
    "transition": 7,
    "mainseg": 0,
{
  "0": {},
  "1": {
    "n": "Halloween",
    "on": true,
    "bri": 255,
    "transition": 7,
    "mainseg": 0,

In same situation I create json file with this text

{
  "0": {}
)

Open WLED-web and execute “restore presets from backup” with this file.

After that all work properly

1 Like

Enable the access point first!
Thanks, this helped!