JackieXie168 / p44mbrd

plan44 matter bridge daemon (companion to vdcd)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

p44mbrd

[if you want to support p44mbrd development, please consider to sponsor plan44]

p44mbrd (plan44 matter bridge daemon) is a free (opensource, GPLv3) matter bridge daemon, intended as a companion to the vdcd home automation controller.

p44mbrd connects vdcd-based devices from many technologies (DALI, EnOcean, hue, SmartLEDs, and many more) into the new smart-home standard matter, making them available in matter-enabled smart home "oecosystems" such as Apple Home, Smart Things, Alexa, Google and hopefully many more independent ones in the near future.

Implementation notes

bridge API

p44mbrd uses a JSON-based representation of the vdc API to communicate with vdcd.

The vdc-API was originally defined in 2013 as an abstraction for the digitalSTROM device model to allow integration of third-party devices into digitalSTROM. The vdc API device model was designed to be as generic as possible, with a strong focus on being self-descriptive through a structured tree of device properties.

This now helps p44mbrd to obtain the needed information from devices to be able to map them to matter bridged device.

matter SDK - connectedhomeip

For the implementation of the matter standard, p44mbrd uses the official Apache 2 licensed matter SDK which is called connectedhomeip.

In particular, p44mbrd was evolved out of the bridge-app example in CHIP.

The connectedhomeip is included as a submodule, but using a plan44 forked github repository.

The forked version is currently needed because things like build support for OpenWrt or the libev based mainloop are not yet part of upstream connectedhomeip. In addition, the forked version omits a lot of very footprint heavy submodules (gigabytes!) containing SDKs for various embedded hardware not relevant to a Linux/Posix based bridge project.

However, the plan44 fork is not a real fork and will not diverge from connectedhomeip a lot. It's just a set of commits on top of connectedhomeip (currently v1.0.0) that will be rebased from time to time to new upstream releases, and hopefully over time get integrated into the SDK itself.

p44utils

p44mbrd is also based on a set of generic C++ utility classes called p44utils, which provides basic mechanisms for mainloop-based, nonblocking I/O driven automation daemons, as well as a script language, p44script. p44utils is included as a submodule into this project.

Early Beta - Work in Progress!

This project is an early beta! It is far from a certifiable (let alone certified) implementation, and has many gaps in functionality. Still, it works pretty nice already with Apple Home at the time of writing.

Expect a lot of changes, refactorings and additions in the next few months!

In particular, connectedhomeip's (and underlying ZCL's) design is very much targeted at devices with a factory-defined static device structure defined at compile time, derived from a static data model laid out in the so-called .zap file generated by the zap tool.

A bridge and its devices however do not have a static structure, but one defined at run time. The bridge-app sample in the matter SDK shows some of the tricks needed to create so-called dynamic endpoints and implement their storage. p44mbrd in its current (October 2022) state is a heavily refactored and modularized version of bridge-app, but still using those rather arcane mechanisms available for dynamic endpoints.

Just recently (in the connectedhomeip master branch, not the v1.0-branch, a new example named dynamic-bridge-app has appeared which seems to address the subject in a less Q&D way than bridge-app did. Maybe there's things to learn from dynamic-bridge-app...

I also plan to look closer into zcl/ember implementation and maybe suggest or help extending it to better support dynamic endpoints from .zap templates instead of all the hand-woven metadata needed right now.

License

p44mbrd is licensed under the GPLv3 License (see COPYING).

If that's a problem for your particular application, I am open to provide a commercial license, within the limits of the third party code included (in particular, connectedhomeip's Apache 2 License) - please contact me at luz@plan44.ch.

Getting Started

try it out

plan44.ch provides RaspberryPi images named P44-DSB-X and P44-LC-X which contain a complete OpenWrt, with vdcd and p44mbrd installed and fully configured as a digitalSTROM bridge or a standalone light controller with matter support. You can download these from https://plan44.ch/automation/p44-dsb-x.php, copy it to a SD Card and use it with a RPi B, B+, 2,3 and 4. Note that the downloaded images are not always the most current version, so use the built-in "check for update" to get the latest version. Also note that at the time of writing this (October 2022) the matter enabled FW is on request, so you need to send an email first (details see https://plan44.ch/p44-techdocs/en/matter/beta_readme/).

build it

You can build p44mbrd using the gn/ninja build system the same way you build any example from the connectedhomeip repository, e.g. as described for the bridge-app example in src/third_party/connectedhomeip/examples/bridge-app/linux/README.md

run it

On a Linux or macOS host, you can run p44mbrd with

${OUT_DIR}/p44mbrd --payloadversion 0 --vendor-id 0xFFF1 --product-id 0x8002 --setuppin 20202021 --discriminator 3842 --KVS /file/to/store/data --chiploglevel 2 --loglevel 5

Note that at this time, all this is not certified by the csa-iot so must use vendor-id and product-id as shown above. These are the test vendor and bridge-app product ids from the SDK. The discriminator should be set to a device-unique value to allow commissioning in a network with multiple bridge-app or p44mbrd instances.

You also need to have a vdcd running on the same host providing the bridge-api on port 4444 (default, you can define other bridge API ports, allow non-local access with vdcd command line options, see --help, and you can tell p44mbrd using --bridgeapihost and bridgeapiport where to look for the bridge API.

Supporting p44mbrd

  1. use it!
  2. support development via github sponsors or flattr
  3. Discuss it in the plan44 community forum.
  4. contribute patches, report issues and suggest new functionality on github or in the forum.
  5. build cool new device integrations and contribute those
  6. Buy plan44.ch products - sales revenue is paying the time for contributing to opensource projects :-)

(c) 2022 by Lukas Zeller / plan44.ch

About

plan44 matter bridge daemon (companion to vdcd)

License:Other


Languages

Language:C 66.2%Language:ZAP 18.2%Language:C++ 15.3%Language:Shell 0.3%