Skip to content

Conversation

digitaldan
Copy link
Contributor

@digitaldan digitaldan commented Apr 4, 2025

The Matter Binding for openHAB allows seamless integration with Matter-compatible devices.

This binding supports 2 different types of matter functionality which operate independently of each other.

  • Matter Client
    • This allows openHAB to discover and control other Matter devices like lights, thermostats, window coverings, locks, etc...
  • Matter Bridge
    • This allows openHAB to expose items as Matter devices to other Matter clients. This allows local control of openHAB devices from other ecosystems like Apple Home, Amazon Alexa, and Google Home.

This has been published on the market place as a 4.x binding for almost 6 months and has seen quite a bit of usage on a variety of networks, platforms and matter devices. So its relatively tested and performing well. I am personally running my home system with 20+ real matter devices (and growing), and using the matter bridge to expose around 100 devices/items to Alexa, Google and Apple for local voice control.

Other openHAB projects that will need enhancements (volunteers wanted !)

There are a lot of moving pieces in this binding, i have started some documentation to help explain this, as well as quite a bit of docs in the README.

A Big thank you to the matter.js team, especially Apollon77 for both developing the matter.js SDK and helping troubleshoot many, many early issues with the binding.

I realize this is going to be a pain to review, so i apologize in advance to our maintainers ;-) The goal is to have this in for the 5.0 release! So hopefully we have enough time.

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
@digitaldan digitaldan added the new binding If someone has started to work on a binding. For a new binding PR. label Apr 4, 2025
@digitaldan digitaldan added this to the 5.0 milestone Apr 4, 2025
@digitaldan digitaldan requested a review from a team as a code owner April 4, 2025 22:37
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
@digitaldan digitaldan added the work in progress A PR that is not yet ready to be merged label Apr 5, 2025
@digitaldan digitaldan changed the title [matter] Initial Commit [matter] Initial Contribution Apr 5, 2025
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
@digitaldan digitaldan removed the work in progress A PR that is not yet ready to be merged label Apr 5, 2025
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
@lsiepel lsiepel added the cre Coordinated Review Effort label Apr 7, 2025
@lsiepel
Copy link
Contributor

lsiepel commented Apr 7, 2025

I can look at the readme, thing structure and java code etc. But i'm no good at the typescript / nodejs / json stuff. Hope others are available to jointly review this.

@lolodomo
Copy link
Contributor

lolodomo commented Apr 7, 2025

Same thing for me.
@lsiepel : we can start by distributing java code ?
I let you take a look to README, I already read it in the past and it was very good in my opinion.
And I can check thing structure if you are ok.

@florian-h05
Copy link
Contributor

I can jump in to take a look at the TypeScript/JavaScript code 👍

@digitaldan
Copy link
Contributor Author

Thanks everyone !

Couple things:

@florian-h05 , I kept the Typescript code at a minimum, as my goal was to keep as much logic as possible in Java land. The matter websocket server is basically a glorified RPC service for the controller side, using the JS equivalent of reflection to execute cluster commands dynamically. The bridge side of the websocket server is a little more complicated, but again i kept the logic there at a minimum, just thin wrappers around device types. Would appreciate your review of all of this. I know there's some cleanup i should probably be doing.

I would not spend to much time (or any) in the code-gen part, fortunately it only needs to be run if there are matter specification changes to generate new Java cluster classes. As you can imagine, creating Java classes from handlebar templates was difficult (but works shockingly well). One thing might be tweaking the templates to produce better formatted code, but the maven build runs spotless against the generated classes as part of the code-gen build task, so maybe not so important.

So the bulk of the logic is in the Java code, hopefully that makes it a bit easier. The DEVELOPMENT.md readme has some info on the structure (client, controller, bridge) , hopefully that helps too.

@lsiepel
Copy link
Contributor

lsiepel commented Apr 7, 2025

Maybe it has been asked before. Is there a specific reason that the client and bridge part are combined into one binding?
Wouldn't it make sense to move the client part to another binding similar to hueemulation, homekit etc?

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @digitaldan for this amazing binding! I will try to help out with the review as well, although with limited capacity and sadly currently no ability to try it out.

I had a very quick look at some of the code, and it already looks quite solid.

I have added a few very minor comments from first iteration through the README.

@digitaldan
Copy link
Contributor Author

Maybe it has been asked before. Is there a specific reason that the client and bridge part are combined into one binding?

I was thinking about this quite a bit actually. And the code is partitioned that way actually. But ultimately my reasoning was this.

  1. The two share a lot of common code , so there would have to be 3 bindings, common, client, and bridge (hence the naming in the source directory structure)
  2. The bridge and client need to run in the same node.js process and do share a global network service in node for shared services like MDNS (this is deep in the matter.js code). This could still be done with a shared 3rd addon (common) as the web socket server/runner is a OSGI singleton service, but now it gets more complicated.
  3. Maybe the most persuasive argument was i wanted users to just be able to install the "Matter" binding and have all functionality available, and not have to install 2 different bindings.

Obviously i was on the fence on this one, but ultimately decided on wanting this easy for users. If there are strong feelings about this, i'm open for further discussion.

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
… upgrades matter sdk

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
@digitaldan
Copy link
Contributor Author

FYI, i forgot that the ConsoleCommandExtension.java file is not complete, i'm hoping to work on it a bit this weekend, but if i don't find time, i just may remove it for now.

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm flushing a few fragmented comments, sorry for that. As I'm trying to acquiant myself with the binding I'm going back and forth through different bits and adding comments along the way. I could hold them back and publish all at once, but the PR would probably be merged by then. 😄

florian-h05 pushed a commit to openhab/openhab-webui that referenced this pull request May 28, 2025
Refs openhab/openhab-addons#18486

---------

Also-by: Florian Hotze <dev@florianhotze.com>
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
@digitaldan
Copy link
Contributor Author

Thanks everyone, i think i have addressed all outstanding comments with my last PR. I would be good merging as is right now, i think its in good shape thanks to the thoughtful reviews. I will follow up this weekend with a few more PRs around TS formatting, more docs, as well as some new devices i have been holding off on adding until this is merged.

@florian-h05
Copy link
Contributor

Let me check the changes this evening 👍

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Copy link
Contributor

@florian-h05 florian-h05 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typescript code LGTM now, apart from the license header in the utils, I don’t know if it should be there.

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
@digitaldan
Copy link
Contributor Author

Just pushed an update to address the last comment, thanks!

@lolodomo
Copy link
Contributor

In case an urgent merge is required, I can already confirm that all my existing comments were properly handled, thank you Dan.

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few questions mainly about ColorControlConverter

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of class MatterControllerClient

* @param nodeId the node ID to get the pairing codes for
* @return a future that completes when the pairing codes are retrieved
*/
public CompletableFuture<PairingCodes> enhancedCommissioningWindow(BigInteger nodeId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't you add JsonParseException as possible thrown exception ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was to add it not only in javadoc but also in method declaration.

@digitaldan
Copy link
Contributor Author

Thanks @lolodomo , i'll have time tomorrow afternoon PDT to address and get a commit posted asap.

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few minor remarks when reviewing partially the handler package

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
@digitaldan
Copy link
Contributor Author

Latest commit should address the latest comments, thanks!

Comment on lines +423 to +424
if (lastOnOff)
updateState(CHANNEL_ID_COLOR_TEMPERATURE, miredsToPercentType(lastColorTemperatureMireds));
Copy link
Contributor

@lolodomo lolodomo Jun 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add {} in a next change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sure.

@lolodomo
Copy link
Contributor

lolodomo commented Jun 1, 2025

@jlaur : I let you the privilege to push the merge button as you are the only one to have done a full review ;)

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this important binding and all the effort invested in this, @digitaldan. Awesome work! 👍 Let's get this merged for the next milestone, and also so the related work in other repos can progress.

@jlaur jlaur merged commit f88de93 into openhab:main Jun 1, 2025
2 checks passed
@jlaur jlaur changed the title [matter] Initial Contribution [matter] Initial contribution Jun 1, 2025
@lolodomo
Copy link
Contributor

lolodomo commented Jun 1, 2025

I plan to run new tests with the official version in the coming days.

@lolodomo
Copy link
Contributor

lolodomo commented Jun 1, 2025

Dan, I was asking myself if you could list what is not yet supported by the binding? Type of devices, certain features, ...

@digitaldan
Copy link
Contributor Author

Yeah, i think putting together a supported matter Device Type list would be good, i'll look into it.

@lolodomo
Copy link
Contributor

lolodomo commented Jun 1, 2025

Dan, I just checked the JSON I sent to you in the past for my Matter lightbulb and colorTempPhysicalMinMireds is 153.
The binding will finally consider 154 as minimum.
Does it mean Tapo is not respecting the Matter standard or does it mean that your minimum value at 154 should be rather 153 ?

I plan to run new tests with the official version in the coming days.

As we have difficulties to build a new snapshot, I compiled the binding form code and installed it in a previous snapshot.

@digitaldan
Copy link
Contributor Author

Sorry, that was my mistake, i meant to test if its == "0" not less then the default min, i'll post a fix right now for that.

@digitaldan
Copy link
Contributor Author

digitaldan commented Jun 1, 2025

Actually, i think i did get it right, if its less then or equal to MIN_MIREDS then we default to a sane value. MIN_MIREDS is 1 (1 is the matter 1.4 default, it was 0 in 1.3 and earlier)

No, your right, i'm doing an unnecessary Math.max on that, i'll fix that and put a test in for it

@lolodomo
Copy link
Contributor

lolodomo commented Jun 8, 2025

Dan, now, you could add the binding's logo to the openHAB website. See https://www.openhab.org/docs/developer/addons/#add-your-add-on-s-logo-to-the-openhab-website

@digitaldan
Copy link
Contributor Author

digitaldan commented Jun 8, 2025

Done!
openhab/openhab-docs#2505

phenix1990 pushed a commit to phenix1990/openhab-addons that referenced this pull request Jul 31, 2025
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cre Coordinated Review Effort new binding If someone has started to work on a binding. For a new binding PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants