home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.79k stars 28.93k forks source link

ZHA install_code incorrectly limited to 18 bytes #44805

Closed atmurray closed 3 years ago

atmurray commented 3 years ago

The problem

When calling the zha.permit service, components/zha/core/helpers.py limits the length to 18 bytes rather than the more broader range of valid lengths that the zigpy convert_install_code supports (8, 10, 14, or 18 bytes).

The following validation message is returned: Failed to call service zha/permit. invalid length of the install code for dictionary value @ data['install_code']

Environment

Problem-relevant configuration.yaml

Traceback/Error logs

Additional information

probot-home-assistant[bot] commented 3 years ago

zha documentation zha source (message by IssueLinks)

Adminiuga commented 3 years ago

Per Zigbee 3 specs and install codes are 18bytes. This feature nis targeted for zb3 devices and still not all zb3 devices come with install codes.

atmurray commented 3 years ago

Zigbee Smart Energy allows for the other formats. See section 3 of this document:

https://www.silabs.com/documents/public/application-notes/an1089-using-installation-codes-with-zigbee-devices.pdf

Is there any downside in allowing the user to enter other code formats? This is only in the user interface, the backend of the integration appears to already support the other formats.

Adminiuga commented 3 years ago

you could bellows command line to join with shorter install codes. Currently there's no support for SE profile, so I don't see much benefit.

If you'd like to test how it work, feel free to modify https://github.com/home-assistant/core/blob/773d95251e37a94fb7baabb576a06e526736d402/homeassistant/components/zha/core/helpers.py#L252

atmurray commented 3 years ago

I'd already commented out that line and it got to my next hurdle: permit_with_key isn't implemented for my zigbee coordinator (xbee).

There is some support for these devices because they support Home Automation and Smart Energy profiles.

By manually generating an encryption key from the install key and setting the whole network to use this as the common join key I was able to add a single device and confirm that there is underlying support for these devices. They're power plugs and I was able to turn one on/off from home assistant so if I can ultimately get these to join using permit_with_key it should work fine.

Hedda commented 3 years ago

Zigbee Smart Energy allows for the other formats.

What device are these exactly? Are you sure they really use the Zigbee Smart Energy (ZSE) profile (a.k.a. Zigbee SE)?

FYI, the Zigbee Smart Energy (ZSE) profile is not part of the ZigBee Pro or Zigbee 3.0 (ZB3) specification standards. Zigbee 3.0 actually incorporate backward compatibility with all Zigbee application layer protocol profiles with the exception of Zigbee Smart Energy (a.k.a. Zigbee SE). Also, note some Zigbee Smart Energy (ZSE) devices use sub-1GHz radio frequencies which are not supported by most Zigbee adapters as not common for home automation as the Zigbee Smart Energy standard is instead most often used for industrial or commercial use for smart metering of electricity, gas and water rather than domotics/home use (other than if your utility company for electricity, gas and water is using ZSE smart meters which is quite common).

https://www.unifore.net/home-alarm-system/introduction-to-zigbee-3-0-zigbee-ha-protocol.html

Zigbee Home Automation (ZHA) Zigbee Light Link (ZLL) 2.0 Zigbee Remote Control (ZRC) 2.0 Zigbee Building Automation (ZBA) Zigbee Retail Services (ZRS) Zigbee Health Care (ZHC) Zigbee Telecommunication services (ZTS)

atmurray commented 3 years ago

What device are these exactly? Are you sure they really use the Zigbee Smart Energy (ZSE) profile (a.k.a. Zigbee SE)?

They're Jetlun RD77715 Appliance Modules: https://fccid.io/X5QRD77715/User-Manual/Users-Manual-1592194

According to their spec they support ZigBeePro Smart Energy 1.1 or Home Automation 1.0. They do run on 2.4GHz and I can talk to it if I configure the network with the Link Key that it expects.

Thanks for the info on ZSE no being included in ZB3, wasn't aware of that.

Hedda commented 3 years ago

They're Jetlun RD77715 Appliance Modules: https://fccid.io/X5QRD77715/User-Manual/Users-Manual-1592194

So it is more or less just a stand-alone smart-plug and not a part of a larger energy metering appliance for electricity, gas or water?

Thanks for the info on ZSE no being included in ZB3, wasn't aware of that.

Maybe the discussion about ZSE support belongs in upstream zigpy instead or? See https://github.com/zigpy/zigpy/discussions

Would be interesting to have support ZSE profile devices via zigpy when supported by the Zigbee stack on the coordinator.

atmurray commented 3 years ago

So it is more or less just a stand-alone smart-plug and not a part of a larger energy metering appliance for electricity, gas or water?

They were previously used as part of a trial of a larger solution that included smart meter and in-home display. That trial ended a while ago and so I'm trying to re-purpose these modules.

atmurray commented 3 years ago

I just received a ZB3 coordinator (a Sonoff ZBBridge now running Tasmota). I can confirm that these devices are able to successfully join the network using the zha.permit service when the code length check is commented out. I can control these devices as a smart plug in HASS but the energy monitoring isn't reporting back valid data - I'll look into this.

If I prepare a pull request to patch helpers.py so that it aligns to the code length check in zigpy will it get accepted?

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.