Breina / ha-artnet-led

DMX lighting Integration for Home Assistant. Using the HA Color Mode update and Pyartnet library to control lights in multiple DMX universes over ethernet with the Art-Net protocol.
MIT License
115 stars 10 forks source link

Error turning light on #8

Closed JohnnyFlash closed 1 year ago

JohnnyFlash commented 2 years ago

I am having an issue with a light converted from custom_white with the jnimmo version of the integration. I recently upgraded HA to 3.9.2 and of course custom_white was broken. I followed recommendations to switch to this version of the integration and it went mostly smoothly.

I converted custom_white entities to color_temp

          - channel: 131
            name: Maker Light 1
            type: color_temp
            channel_setup: dt

However, now when I attempt to turn on the light I get the following error - failed to call service light/turn_on

My RGB light bars still work correctly as type: rgb

Breina commented 2 years ago

Can you show me under the attributes what the value is of 'Dmx values'? This config does seem to be correct.

image

Think it might be related to the migration process itself; try completely removing the integration and re-adding it once again?

To find the root cause, it would help me a bit if you could include the bit from the logs around this error.

JohnnyFlash commented 2 years ago

Here is the associated image and log messages.

image

2022-09-13 14:59:41.114 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140093288016256] Received {'type': 'call_service', 'domain': 'light', 'service': 'turn_on', 'service_data': {'entity_id': 'light.maker_light_2'}, 'id': 27}
2022-09-13 14:59:41.115 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.maker_light_2>
2022-09-13 14:59:41.116 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: EventTask(event=<Event call_service[L]: domain=light, service=turn_on, service_data=entity_id=light.maker_light_2>)
2022-09-13 14:59:41.116 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140093288016256] 
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 199, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 676, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 930, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 713, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/light/__init__.py", line 553, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/config/custom_components/artnet_led/light.py", line 496, in async_turn_on
    await super().async_create_fade(**kwargs)
  File "/config/custom_components/artnet_led/light.py", line 276, in async_create_fade
    self._channel.add_fade(
  File "/usr/local/lib/python3.10/site-packages/pyartnet/dmx_channel.py", line 83, in add_fade
    assert 0 <= k.val_target <= (256 ** self._CHANNEL_SIZE) - 1
AssertionError
2022-09-13 14:59:41.121 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection] [140093288016256] Sending {"id":27,"type":"result","success":false,"error":{"code":"unknown_error","message":""}}
Breina commented 2 years ago

I published a quick v0.0.5 that will prevent crashing the flow and instead will print a warning message. It doesn't fix the root cause, but at least it will reduce the severity of the error.

After updating, could you please find this log line for me?

log.warning(f"Value for channel {channel} isn't within bound: {value}")

JohnnyFlash commented 2 years ago

Lights are working-ish.

I have noticed that the control bars seem skewed. For instance 0% brightness is around the middle of the the brightness bar.

Here's the data you were looking for. [custom_components.artnet_led.light] Value for channel t isn't within bound: -45.82949308755758

Breina commented 2 years ago

Ah I see, that explains it. The brightness is set by HA itself, I'm not even touching that. I think that the color temperature value coming from HA is also offset similarly. It's giving you values that are outside of its own specification.

It might have to do with the data model of ATTR_WHITE_VALUE being interpreted as a ATTR_COLOR_TEMP. I know it's annoying, but I think perhaps it's best if you do a clean install:

  1. Remove, or comment out, the config of the faulty lights
  2. Restart HA
  3. Remove the entities of the faulty lights
  4. Put back the config
  5. Restart HA
Breina commented 1 year ago

@JohnnyFlash Did that latest procedure fix it for you?