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

ZHA and Bosch Twinguard gives stack trace and "Failed to perform the action zha.permit. Unknown error" / Status.UNSUPPORTED #134899

Open
raoulbhatia opened this issue Jan 6, 2025 · 6 comments

Comments

@raoulbhatia
Copy link

raoulbhatia commented Jan 6, 2025

The problem

I am trying to add a Bosch Twinguard to my ZHA installation on

  • Home Assistant: 2024.12.5
  • Coordinator: ConBee3
  • Coordinstor firmware version: 0x26530900

Per zigpy/zigpy-deconz#214 this should be supported.

I followed the steps mentioned at https://www.home-assistant.io/integrations/zha#action-zhapermit
using the QR code I scanned from the device.

Even as the QR code support of Bosch is NOT in the list in your documentation,
I think this action should not give a stack trace but should give a clear error message instead.

Error message observed in the UI: Failed to perform the action zha.permit. Unknown error
Error message in the stack trace: zigpy_deconz.exception.CommandError: <CommandId.write_parameter: 11>, status: <Status.UNSUPPORTED: 4>

What version of Home Assistant Core has the issue?

core-2024.12.5

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ZHA with Bosch Twinguard Sensor

Link to integration documentation on our website

https://www.home-assistant.io/integrations/zha#action-zhapermit

Diagnostics information

config_entry-zha-01JGY40MWRS0FGTN2SXK4K7T2M.json

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2025-01-06 16:50:08.316 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: <CommandId.write_parameter: 11>, status: <Status.UNSUPPORTED: 4>
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  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 1110, in _async_admin_handler
    await result
  File "/usr/src/homeassistant/homeassistant/components/zha/websocket_api.py", line 1295, in permit
    await application_controller.permit_with_link_key(
        time_s=duration, node=src_ieee, link_key=link_key
    )
  File "/usr/local/lib/python3.13/site-packages/zigpy_deconz/zigbee/application.py", line 116, in permit_with_link_key
    await self._api.write_parameter(
    ...<2 lines>...
    )
  File "/usr/local/lib/python3.13/site-packages/zigpy_deconz/api.py", line 848, in write_parameter
    await self.send_command(
    ...<3 lines>...
    )
  File "/usr/local/lib/python3.13/site-packages/zigpy_deconz/api.py", line 507, in send_command
    return await self._command(cmd, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/zigpy_deconz/api.py", line 588, in _command
    return await fut
           ^^^^^^^^^
zigpy_deconz.exception.CommandError: <CommandId.write_parameter: 11>, status: <Status.UNSUPPORTED: 4>
2025-01-06 16:50:08.325 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [281472131859936] Error handling message: Unknown error (unknown_error) Raoul Bhatia from 172.30.33.4 (Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; 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/websocket_api/commands.py", line 816, in handle_execute_script
    script_result = await script_obj.async_run(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        msg.get("variables"), context=context
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1801, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 528, in _async_step
    self._handle_exception(
    ~~~~~~~~~~~~~~~~~~~~~~^
        ex, continue_on_error, self._log_exceptions or log_exceptions
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 558, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ...<9 lines>...
    )
    ^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 727, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  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 1110, in _async_admin_handler
    await result
  File "/usr/src/homeassistant/homeassistant/components/zha/websocket_api.py", line 1295, in permit
    await application_controller.permit_with_link_key(
        time_s=duration, node=src_ieee, link_key=link_key
    )
  File "/usr/local/lib/python3.13/site-packages/zigpy_deconz/zigbee/application.py", line 116, in permit_with_link_key
    await self._api.write_parameter(
    ...<2 lines>...
    )
  File "/usr/local/lib/python3.13/site-packages/zigpy_deconz/api.py", line 848, in write_parameter
    await self.send_command(
    ...<3 lines>...
    )
  File "/usr/local/lib/python3.13/site-packages/zigpy_deconz/api.py", line 507, in send_command
    return await self._command(cmd, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/zigpy_deconz/api.py", line 588, in _command
    return await fut
           ^^^^^^^^^
zigpy_deconz.exception.CommandError: <CommandId.write_parameter: 11>, status: <Status.UNSUPPORTED: 4>


### Additional information

Related to zigpy/zigpy-deconz#214 and Koenkk/zigbee-herdsman#1184
@home-assistant
Copy link

home-assistant bot commented Jan 6, 2025

Hey there @dmulcahey, @Adminiuga, @puddly, @TheJulianJES, mind taking a look at this issue as it has been labeled with an integration (zha) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of zha can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign zha Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


zha documentation
zha source
(message by IssueLinks)

@puddly
Copy link
Contributor

puddly commented Jan 6, 2025

What adapter are you using and what firmware version is it running?

@raoulbhatia
Copy link
Author

raoulbhatia commented Jan 6, 2025

Apologies for missing to provide this information

  • coordinator: ConBee3
  • firmware version: 0x26530900

@puddly
Copy link
Contributor

puddly commented Jan 6, 2025

The Conbee III probably doesn't support link keys. It may superficially communicate with the same protocol as the Conbee II but it's a completely different implementation underneath.

@raoulbhatia
Copy link
Author

Per http://deconz.dresden-elektronik.de/raspbian/deCONZ-Serial-Protocol_en_1.22.pdf it should support it.

"2.1 Required Hardware" mentions ConBee III specifically

"6.2.3 Zigbee Install Codes" states

The Serial Protocol and firmware doesn’t support Zigbee Install Codes directly. In order to join a device via Install Code, a device specific Link Key needs to be derived from the Install Code by the host application.

This 16-byte Link Key together with the device MAC address can than be configured by a Write Parameter Request (0×0B) for the Link Key parameter (0×19).

Once configured, during joining process, the device will receive the Network Key encrypted with the Link Key instead of the global Truster Center Link Key.

A C++ OpenSSL reference implementation for the key derivation can be found at:
https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/crypto/mmohash.cpp

@puddly
Copy link
Contributor

puddly commented Jan 6, 2025

The implementation in zigpy-deconz has been tested successfully with a Conbee II so the protocol-level part should be correct: you write the device EUI64 + link key to the link_key parameter.

On the Conbee II, this works fine. On the Conbee III, you get zigpy_deconz.exception.CommandError: <CommandId.write_parameter: 11>, status: <Status.UNSUPPORTED: 4>. Like I said before, the Conbee III is a completely different radio with a firmware compatibility layer. It's very likely that this isn't implemented (or if it is, it's done in a different way and not documented).

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

No branches or pull requests

5 participants