kardia-as / zigpy-zboss

GNU General Public License v3.0
39 stars 4 forks source link

Introduce compatibility with recent zigpy changes and improve UART reset stability #51

Closed puddly closed 3 months ago

puddly commented 5 months ago

This is a fairly large and disorganized PR to get the radio library working with zigpy-cli and ZHA. Main changes are:

  1. Remove probe, as zigpy now handles this by trying to connect.
  2. Remove all reconnection logic from the radio library. This is now handled by ZHA (or the upstream application).
  3. Load coordinator info, if possible, into node_info.model and node_info.manufacturer.
  4. Get api.reset() working properly by internally handling reconnection to the UART.
  5. Make sure network formation is completely stable:
    • reset, form, then backup should erase the old network completely and form a new one with random settings.
    • Running reset and form again will erase them, like before.
    • Running restore should bring back the old settings exactly: diff backup1.json backup2.json should differ only by the backup_time and NWK frame counter, everything else should be identical.
  6. Logging cleanup. I've moved listener-related messages to a separate logger, as otherwise the CLI was unreadably verbose.

A few things are left:

  1. Allow overriding the manufacturer code during joining so that new Aqara devices stay on the network: https://github.com/zigpy/bellows/blob/eae32eaf1158e0b9a6180e9b400f350ac96975a9/bellows/zigbee/application.py#L63-L66 (this should probably be moved to zigpy)
  2. Write unit tests so that any changes to zigpy can be tested against this library without having to run it.
  3. Replace zboss.types.basic, etc. with zigpy.types.basic: we want all radio libraries to use zigpy types wherever possible.
  4. Migrate to the zigpy pre-commit hooks so that auto code formatting works again.
  5. Run it for a few weeks on a production network to see if anything breaks 😄.

This radio library is looking really nice, the ZBOSS serial protocol and command set looks extensive and well-designed!

puddly commented 5 months ago

With these changes, I am able to get ZHA running with a nRF52840 stick and have migrated a functional test network to the ZBOSS radio. It continues to work fine and I can control devices. Commands, however, are inconsistent and sometimes have multi-second delays.

puddly commented 3 months ago

@DamKast Let me know if there's anything else I can do to get this PR merged.

DamKast commented 3 months ago

I am sorry it took so much time. Thanks a lot for the updates.