Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"3072 is not a valid ModeColors" #69

Open
Bluscream opened this issue Nov 17, 2023 · 3 comments · May be fixed by #72
Open

"3072 is not a valid ModeColors" #69

Bluscream opened this issue Nov 17, 2023 · 3 comments · May be fixed by #72

Comments

@Bluscream
Copy link

Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/commands.py:230
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 3:15:26 PM (3 occurrences)
Last logged: 3:15:34 PM

[547292370240] 3072 is not a valid ModeColors
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 230, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 2035, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2072, 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 876, in entity_service_call
    response_data = 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/light/__init__.py", line 580, in async_handle_light_on_service
    await light.async_turn_on(**filter_turn_on_params(light, params))
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1265, in async_turn_on
    await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/openrgb/light.py", line 173, in turn_on
    self._set_color()
  File "/config/custom_components/openrgb/light.py", line 334, in _set_color
    self._light.set_color(RGBUtils.RGBColor(*color))
  File "/usr/local/lib/python3.11/site-packages/openrgb/orgb.py", line 190, in set_color
    self.update()
  File "/usr/local/lib/python3.11/site-packages/openrgb/utils.py", line 670, in update
    self.comms.requestDeviceData(self.device_id)
  File "/usr/local/lib/python3.11/site-packages/openrgb/network.py", line 181, in requestDeviceData
    self.read()
  File "/usr/local/lib/python3.11/site-packages/openrgb/network.py", line 137, in read
    self.callback(device_id, packet_type, utils.ControllerData.unpack(data, self._protocol_version))
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openrgb/utils.py", line 552, in unpack
    mode = ModeData.unpack(data, version, x)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/openrgb/utils.py", line 327, in unpack
    color_mode = ModeColors(parse_var('I', data))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 712, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/enum.py", line 1135, in __new__
    raise ve_exc
ValueError: 3072 is not a valid ModeColors

Erroring device is:

@trajano
Copy link

trajano commented May 10, 2024

The problem is on this line

color_mode = ModeColors(parse_var('I', data))

The reason for it is it's assuming that there is a limited set of ModeColors defined in

class ModeColors(IntEnum):
but the specs actually indicate that it is a uint32 and can vary between devices.

As such that assumption on the possible ModeColors is incorrect, I am getting a similar issue as you are. What I did for now was hard code it to use MODE_SPECIFIC for now

        # color_mode = ModeColors(parse_var('I', data))
        parse_var('I', data)
        color_mode = ModeColors.MODE_SPECIFIC

but ideally I think color_mode should be an integer.

trajano added a commit to trajano/openrgb-python that referenced this issue May 11, 2024
@trajano trajano linked a pull request May 11, 2024 that will close this issue
@jath03
Copy link
Owner

jath03 commented May 12, 2024

@trajano
Copy link

trajano commented May 12, 2024

Thanks I'll see if I can do something about it in my PR but feel free to modify the PR to match. The main purpose was to make sure it does not crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants