Xinyuan-LilyGO / T-ZigBee

Zigbee Ultra Low Power IOT Development Board
GNU Affero General Public License v3.0
77 stars 21 forks source link

[REQUEST] Telink radio library for zigpy + a Zigbee serial API proxy/bridge mode? #3

Open Hedda opened 2 years ago

Hedda commented 2 years ago

Any chance you would consider adding a Zigbee serial API proxy/bridge and making a Telink radio library (in Python) for zigpy?

https://github.com/zigpy/zigpy

https://github.com/zigpy/zigpy-cli

zigpy is an open-source Python library implementing Zigbee serial API hardware-independent abstraction for radio manufacturers and a few popular home automation application projects depend on zigpy, including ZHA for Home Assistant, Zigbee plugin for Domoticz, and Zigbee plugin for Jeedom:

https://www.home-assistant.io/integrations/zha

https://www.domoticz.com/wiki/ZigbeeForDomoticz

https://doc.jeedom.com/en_US/plugins/automation%20protocol/zigbee/

So all and any Zigbee Coordinator adapters that have a radio library for zigpy can be used with ZHA, Domoticz, and Jeedom:

https://github.com/zigpy/zigpy-znp

https://github.com/zigpy/zigpy-deconz

https://github.com/zigpy/bellows

https://github.com/zigpy/zigpy-zigate

https://github.com/zigpy/zigpy-xbee

lbuque commented 2 years ago

Is there any relevant zigpy documentation? I did not find it

Hedda commented 2 years ago

@liangyingy Please understand that those zigpy libraries is a free and open-source project developed by volunteers from the DIY home automation software communities in their spare time so unfortunately there is not a lot of documentation, instead, if you (or Telink) are interested in taking on this project you would primarily have to look at the existing radio libraries like the zigpy-znp radio library (alternatively bellows or zigpy-deconz) to see how the hardware API translation is done from proprietory API to the zigpy radio API which is meant to be unified for all zigpy radio APIs. Then of course create an issue or discussion to post questions on specific problems if you get stuck or need feedback.

Before looking at the code should first read this document -> https://github.com/zigpy/zigpy/blob/dev/CONTRIBUTING.md

For reference, you can see the somewhat similar discussion here about creating a new radio library for zigpy-> https://github.com/zigpy/zigpy/issues/394

Note! @puddly is working on updating the zigpy radio API making all radio libraries more unified, see -> https://github.com/zigpy/zigpy-cli/pull/2

Therefore if starting before those changes are merged it would currently probably be best to look at his development branches:

https://github.com/puddly/zigpy-cli/tree/puddly/zigpy-radio-api

https://github.com/puddly/zigpy/tree/puddly/new-radio-settings-api

https://github.com/puddly/zigpy-znp/tree/puddly/new-radio-settings-api

https://github.com/puddly/bellows/tree/puddly/zigpy-radio-api

https://github.com/puddly/zigpy-deconz/tree/puddly/new-radio-api

PS: If you are or Telink are interested in taking on this project then suggest you post a new issue or discussion to the zigpy project:

https://github.com/zigpy/zigpy/issues

https://github.com/zigpy/zigpy/discussions

Hedda commented 2 years ago

Note! @puddly is working on updating the zigpy radio API making all radio libraries more unified, see -> zigpy/zigpy-cli#2

Therefore if starting before those changes are merged it would currently probably be best to look at his development branches:

https://github.com/puddly/zigpy-cli/tree/puddly/zigpy-radio-api

https://github.com/puddly/zigpy/tree/puddly/new-radio-settings-api

https://github.com/puddly/zigpy-znp/tree/puddly/new-radio-settings-api

https://github.com/puddly/bellows/tree/puddly/zigpy-radio-api

https://github.com/puddly/zigpy-deconz/tree/puddly/new-radio-api

FYI, all the pull requests for the zigpy radio API has now been marged, see -> https://github.com/zigpy/zigpy-cli/pull/2

That means that no longer need to look at puddly's development branches but can look directly at the main repositories:

https://github.com/zha-ng/zigpy-znp

https://github.com/zigpy/zigpy-deconz

https://github.com/zigpy/bellows

https://github.com/zigpy/zigpy-xbee

https://github.com/zigpy/zigpy-zigate

Hedda commented 2 years ago

FYI, zigpy developer puddly has begun preliminary work on a new radio API for zigpy as well as on merging radio libraries respective high-level functions and command-line tools into zigpy-cli. Still very early on thus now would be a great time for Zigbee radio developers to start giving your feedback and input on the design of this new unified Zigbee CLI for zigpy which is meant as a common support for all radio manufacturers. See:

https://github.com/zigpy/zigpy-cli/ (and https://github.com/zigpy/zigpy-cli/issues plus there zigpy/zigpy-cli#5)

At the moment he is focusing on completely exposing the low-level network and node info, (for example energy scanning already works with TI ZNP and the deCONZ ConBee/RaspBee using the same code however the zigpy-znp command line tool just needs to be transplanted into zigpy-cli), so if you want a chance to influence what should go into that zigpy CLI versus what should go into the separate zigpy radio libraries for each manufacturer then now would be the best time to begin contributing.

  • This new CLI as a standard radio settings API is primarily being discussed here -> [RFC] Standard radio settings API #842
  • Development started here -> New radio API #848
  • Cross-radio backup and restore -> Implement new radio API zigpy-cli#2
  • pully mentioned that he is eventually planning on trying to add a similar shell using IPython for sending commands interactively ("since it has autocompletion and is async-friendly").
  • pully also mentioned that bootloader commands are low on the priority list, "since that code is often pretty complex and uses internal radio library code. A plugin system could work, but since the existing bootloader tools are synchronous, it'd take either a complete rewrite to work with zigpy-cli, or the tools would essentially be run externally in a separate thread, which is no easier than directly running the original tools."

FYI, puddly has now merged the new radio API so all of zigpy radio libraries should now use the new unified API.

Hedda commented 1 year ago

Tip on another possible alternative ESP32 target hardware for that described scenario could be the Espressif ESP32-C6 SoC series which add an integrated 802.15.4 radio that supports Zigbee 3.0 (and Thread). See related discussion here -> https://github.com/zigpy/zigpy/discussions/783

PS: I believe that those with Espressif contacts can get such DevKit boards for evaluation upon request(?) -> sales@espressif.com

lbuque commented 1 year ago

@Hedda You can check this discussion #22, I made a light device using esp32-c6 and successfully added it to home assistant.