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

Quirk ZCLCommandDef name attribute makes unable to call command #1520

Open
tomleglaunec opened this issue Dec 12, 2024 · 0 comments
Open

Quirk ZCLCommandDef name attribute makes unable to call command #1520

tomleglaunec opened this issue Dec 12, 2024 · 0 comments

Comments

@tomleglaunec
Copy link

Encountered when trying to setup a quirk V2 for a custom made zigbee device (with out of spec clusters).
Basic custom cluster definition to reproduce:

class ExampleCluster(CustomCluster, BinaryInput):
    class ServerCommandDefs(BinaryInput.ServerCommandDefs):
        custom_command: Final = ZCLCommandDef(
            id=0xfe,
            schema={},
            direction=Direction.Client_to_Server,
            is_manufacturer_specific=True,
            name="my_custom_command"
            )

When the quirk is applied, the command will fail to load in the 'manage zigbee device -> ExampleCluster -> Commands' with the following exception:

image

[548245506368] Error handling message: Unknown error (unknown_error) admin from fe80::93d5:1090:4319:d1b2 (Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/zha/websocket_api.py", line 810, in websocket_device_cluster_commands
    cluster_command_schema_to_vol_schema(cmd.schema),
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/helpers.py", line 1077, in cluster_command_schema_to_vol_schema
    for field in schema.fields
                 ^^^^^^^^^^^^^
AttributeError: 'dict' object has no attribute 'fields'

And if using a command_button() quirk builder, the following exception is raised when the button is pressed in the UI:

2024-12-12 09:46:49.676 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [548245506368] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service
    response = await hass.services.async_call(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<7 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2802, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2845, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1007, in entity_service_call
    single_response = await _handle_entity_call(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
        hass, entity, func, data, call.context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1079, in _handle_entity_call
    result = await task
             ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/button/__init__.py", line 132, in _async_press_action
    await self.async_press()
  File "/usr/src/homeassistant/homeassistant/components/zha/helpers.py", line 1335, in handler
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/zha/button.py", line 60, in async_press
    await self.entity_data.entity.async_press()
  File "/usr/local/lib/python3.13/site-packages/zha/application/platforms/button/__init__.py", line 107, in async_press
    await command(*arguments, **kwargs)
  File "/usr/local/lib/python3.13/site-packages/zha/zigbee/cluster_handlers/__init__.py", line 85, in wrapper
    return await RETRYABLE_REQUEST_DECORATOR(func)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/zigpy/util.py", line 136, in retry
    return await func()
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/zigpy/quirks/__init__.py", line 263, in command
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
    ...<8 lines>...
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/zigpy/zcl/__init__.py", line 355, in request
    hdr, request = self._create_request(
                   ~~~~~~~~~~~~~~~~~~~~^
        general=general,
        ^^^^^^^^^^^^^^^^
    ...<11 lines>...
        kwargs=kwargs,
        ^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/zigpy/zcl/__init__.py", line 313, in _create_request
    request = schema(*args, **kwargs)  # type:ignore[operator]
TypeError: 'dict' object is not callable

Without the name it works perfectly, even tho the button calls its attribute: command_button(name=ExampleCluster.ServerCommandDefs.custom_command.name,...)

Interestingly, the same command maps to a different button entity wether the name is given or not.

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

No branches or pull requests

1 participant