Error using light services with WLED device

I have one WLED device that is giving me all kinds of trouble. It likes to crash when I attempt to use the light.turn_off/light.turn_on service, and it perpetually becomes unavailable as a result. It also prevents certain automations from completing when trying to use these services in an automation. Here are my error logs:

Error executing service: <ServiceCall light.turn_off (c:01GK8SS8ZGR9R47P8HA695NX5K): entity_id=['light.front_house_led_master'], params=>

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/wled/wled.py", line 178, in request
    response = await self.session.request(
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 559, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 898, in start
    message, payload = await protocol.read()  # type: ignore[union-attr]
  File "/usr/local/lib/python3.10/site-packages/aiohttp/streams.py", line 616, in read
    await self._waiter
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/wled/wled.py", line 177, in request
    async with async_timeout.timeout(self.request_timeout):
  File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 129, in __aexit__
    self._do_exit(exc_type)
  File "/usr/local/lib/python3.10/site-packages/async_timeout/__init__.py", line 212, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/wled/helpers.py", line 29, in handler
    await func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/wled/light.py", line 87, in async_turn_off
    await self.coordinator.wled.master(on=False, transition=transition)
  File "/usr/local/lib/python3.10/site-packages/wled/wled.py", line 344, in master
    await self.request("/json/state", method="POST", data=state)
  File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/wled/wled.py", line 209, in request
    raise WLEDConnectionTimeoutError(
wled.exceptions.WLEDConnectionTimeoutError: Timeout occurred while connecting to WLED device at 192.168.7.100

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/core.py", line 1762, in catch_exceptions
    await coro_or_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 208, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 943, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 581, in async_handle_light_off_service
    await light.async_turn_off(**filter_turn_off_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/wled/helpers.py", line 35, in handler
    raise HomeAssistantError("Error communicating with WLED API") from error
homeassistant.exceptions.HomeAssistantError: Error communicating with WLED API

 Error fetching wled data: Invalid response from API: Timeout occurred while connecting to WLED device at 192.168.7.100 
[139633338513056] unexpected end of data: line 1 column 2931 (char 2930)

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1744, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1781, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 208, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 943, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 570, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/components/wled/helpers.py", line 29, in handler
    await func(self, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/components/wled/light.py", line 97, in async_turn_on
    await self.coordinator.wled.master(
  File "/usr/local/lib/python3.10/site-packages/wled/wled.py", line 344, in master
    await self.request("/json/state", method="POST", data=state)
  File "/usr/local/lib/python3.10/site-packages/backoff/_async.py", line 151, in retry
    ret = await target(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/wled/wled.py", line 197, in request
    response_data = await response.json()
  File "/usr/src/homeassistant/homeassistant/helpers/aiohttp_client.py", line 52, in json
    return await super().json(*args, loads=loads, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client_reqrep.py", line 1119, in json
    return loads(stripped.decode(encoding))
orjson.JSONDecodeError: unexpected end of data: line 1 column 2931 (char 2930)

 :0:0 ResizeObserver loop completed with undelivered notifications. 

What gives? Could I have a bad ESP866 board? My WiFi signal to the device is strong, -61dbm.

I have tested this issue on multiple devices and it actually appears linked to an apparent bug in Home Assistant that occurs with WLED devices using a high number of segments (at least 12-14).

The issue has been reported here: WLED Integration crashes when using master segment with high number of segments · Issue #83431 · home-assistant/core · GitHub

Very old post and i am sorry to bring this back, but in the latest version of HA i still face the same errors. My LED strip has 15 segments and if it is used in an automation i get the following error:

Has anyone found any solution?

EDIT: Adding Logs:

Logger: homeassistant.helpers.script.websocket_api_script
Source: helpers/script.py:468
First occurred: 11:49:56 (4 occurrences)
Last logged: 11:51:08

websocket_api script: Error executing script. Unexpected error for device at pos 1: no digit after exponent sign: line 1 column 2711 (char 2710)
websocket_api script: Error executing script. Unexpected error for device at pos 1: unexpected character: line 1 column 2710 (char 2709)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 468, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 720, in _async_device_step
    await device_action.async_call_action_from_config(
  File "/usr/src/homeassistant/homeassistant/components/device_automation/action.py", line 71, in async_call_action_from_config
    await platform.async_call_action_from_config(hass, config, variables, context)
  File "/usr/src/homeassistant/homeassistant/components/select/device_action.py", line 121, in async_call_action_from_config
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2067, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2104, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service
    return await service.entity_service_call(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 878, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 948, 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 101, 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 71, in json
    return await super().json(*args, loads=loads, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/aiohttp/client_reqrep.py", line 1181, in json
    return loads(stripped.decode(encoding))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/json.py", line 43, in json_loads
    return orjson.loads(__obj)  # type:ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^
orjson.JSONDecodeError: no digit after exponent sign: line 1 column 2711 (char 2710)

Thanks
KR

My original issue on GitHub went stale, but I do not have the same use case for WLED in my setup anymore, so this is a non-issue for me.

You could open a new issue on GitHub to get some fresh eyes on the issue.