Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClientCluster implementation example #166

Open
mow opened this issue May 26, 2023 · 5 comments
Open

ClientCluster implementation example #166

mow opened this issue May 26, 2023 · 5 comments
Labels
question Further information is requested

Comments

@mow
Copy link

mow commented May 26, 2023

Hello, thanks for the library, I assume (hope:) I'll contribute a lot in time.

I already implemented the followings:

  • Thermostat Cluster (tested & working)
  • Fan Control Cluster (tested & working)
  • Thermostat Device (tested & working)
  • HVAC Device (stuck :( due to not knowing the mysterious way of adding a client cluster)

I'll create PR's for all of them, but before I need understand how to implement a client cluster for a device. As you know a heating-cooling device (0x300) depends on "thermostat cluster client", can you please provide an example about creating cluster clients, I'm using bridge device node to test the new device implementations, I assume that I'll need the endpoint id of thermostat device added to the aggregator, this is ok, but how should I handle the remaining?

It shoudn't be this hard, I feel that I'm missing something :)

@Apollon77
Copy link
Collaborator

Apollon77 commented May 27, 2023

Hi @mow great to hear that!

We are currently about to modify the Cluster gneration a but and remove again the ClusterExtend approach because it got to complex, so it could be that some adjustments will be needed. The current approach which is discussed can be seen in https://github.com/project-chip/matter.js/pull/165/files#diff-7a1cae91ba88568f50b6f19025c6031c6d748c9f83c26ac28205593e62bada77 on example of WindowCovering. The basic idea is to define more details when an attribute/event/command is conditional (feature specific mandatory or optional) in one cluster file. Then we pan to build a generator which is generating the concrete featurespecific clusters code to be used then. This will be more simple when creating cluster definitions on the long run.

For cluster clients in fact yu do not do anything code wise because this will be automatically wired later on. so for now defining the ThermostatCluster is enough to later use that as Server or as client.

After my vacation one topic on my list is to dive into specs to find out how it works. From my understanding it is that the "Binding" cluster allows to "bind" a thermostat as client to a HVAC device, but we need to find out the details. So ideally this is all automatically configured by the binding cluster. But how it is supposed to work in the end (e.g. will the device then subscribe all attribute changes for the bound device and ... does what with them internally?) ... So we need to understand how all that is intended to work and implement it.

Additionally for this to work I also need to do a bigger internal messaging refactoring to really allow a device to act as client and server at the same time communication wise. So also that might need some time, but is also planned next.

So it is a bit too early for device types which require client clusters. We need to prepare the basics for this first.

But for all this to be able the clusters are the important forst step

@Apollon77 Apollon77 added the question Further information is requested label May 27, 2023
@mow
Copy link
Author

mow commented May 29, 2023

thanks for the explanation @Apollon77! the primary problem I face currently is lack of matter device support knowledge, documentation and implementation details for both apple and google home, e.g. currently fan control device only works as on/off on both mobile platforms but on the nest hub you can control percentSetting additionally, this cluster has more than 5 attributes but only one of them is controllable from the devices I mentioned.

None of the platforms recognizes a heating cooling device unfortunately (tested without a thermostat client). Considering that the primary aim is to "control" the devices, if these platforms are not supporting them yet, no need to be in a rush to implement these at least in details, I agree that it's too early also for the other side.

@Apollon77
Copy link
Collaborator

I agree, this is also a bit unknown always when testing. To verify that you could check if there is a reference app in the Chip tool examples and if how this reacts with apple/google. If the same it is not because of we do stuff incorrectly. In the main matter.js repo there are also links to "what they support" pages from Apple and google. We could also verify there.

But nevertheless working on completing cluster support is good for us to be prepared when the big ones add support ;-))

Maybe wait until #165 is finalized and then being in accordingly. Alternative bring in as it is fine now with ClusterExtend and I convert after 165 landed. Both possible.

@mow
Copy link
Author

mow commented May 30, 2023

Already tested with chip-tool, attributes seems working with it but a heating/cooling device is not yet present in chip-tool even :) not recognized somehow.

Here is my draft pull request: #169 we can proceed whatever you decide.

@Apollon77
Copy link
Collaborator

Cool. I will review after my vacation.

For cluster client I got some infos. In fact most devices in matter spec do not really define how (especially optional) cluster clients on a device should be used. If this is the case then it is up to the implementor. That means that matter.js will check the binding cluster details and setup clusterClients internally for each defined binding and automatically subscribe the values and also check for group messages (later when implemented) and provide callbacks/listeners for that, so that the implementor can define himself what should be done with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants