WLED preset errors

Had to restore backed up config & presets for a WLED device and HA is throwing a fit when I use the presets. Searching around revealed it’s likely a corrupted preset json. Did json and utf-8 validations on that and the configuration backups; found no errors. Manually went through the files to the error locations and retyped the characters again; no change. Reset the device and restored the presets using the original API commands without restoring the preset backup. Nothing I’m doing is stopping this error

Logger: homeassistant.components.websocket_api.http.connection
Source: helpers/aiohttp_client.py:73
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 09:30:27 (14 occurrences)
Last logged: 11:03:01

[139680863948480] 'utf-8' codec can't decode byte 0xc0 in position 861: invalid start byte
[139680859908928] 'utf-8' codec can't decode byte 0xe8 in position 863: invalid continuation byte
[139680867934144] 'utf-8' codec can't decode byte 0xff in position 1086: invalid start byte
[139680850886976] 'utf-8' codec can't decode byte 0xc2 in position 863: invalid continuation byte
[139681106298432] 'utf-8' codec can't decode byte 0x95 in position 861: invalid start byte
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 226, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1974, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2011, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 235, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 870, in entity_service_call
    response_data = await _handle_entity_call(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 942, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/select/__init__.py", line 106, in async_select_option
    await entity.async_select_option(option)
  File "/usr/src/homeassistant/homeassistant/components/wled/helpers.py", line 28, in handler
    await func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/wled/select.py", line 102, in async_select_option
    await self.coordinator.wled.preset(preset=option)
  File "/usr/local/lib/python3.11/site-packages/wled/wled.py", line 553, in preset
    await self.request("/json/state", method="POST", data={"ps": preset})
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wled/wled.py", line 211, in request
    response_data = await response.json()
                    ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 73, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1120, in json
    return loads(stripped.decode(encoding))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x9f in position 861: invalid start byte
1 Like

I’m actually running into the same problem. WLED has no issues importing my fairly basic ~60 presets that were created 2 days ago (current version). As soon as I import the presets, this node goes unavailable in the integration with the error shown above. As the original poster states, it feels like something is malformed. These were carefully backed up as soon as they were created, so I don’t really understand where any corruption could be occurring. WLED is happy with it, but the integration is not happy reading it.

Logger: homeassistant.components.wled
Source: helpers/aiohttp_client.py:72
Integration: WLED (documentation, issues)
First occurred: 11:33:14 AM (16 occurrences)
Last logged: 11:43:47 AM

Unexpected error fetching wled data: 'utf-8' codec can't decode byte 0xff in position 5577: invalid start byte
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 293, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/wled/coordinator.py", line 103, in _async_update_data
    device = await self.wled.update(full_update=not self.last_update_success)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wled/wled.py", line 294, in update
    if not (presets := await self.request("/presets.json")):
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/wled/wled.py", line 211, in request
    response_data = await response.json()
                    ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 72, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1120, in json
    return loads(stripped.decode(encoding))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 5577: invalid start byte