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

Add Unknown command support for ClusterClients (API and shell) #1053

Open
dev-pobo opened this issue Jul 27, 2024 · 8 comments
Open

Add Unknown command support for ClusterClients (API and shell) #1053

dev-pobo opened this issue Jul 27, 2024 · 8 comments
Labels
enhancement New feature or request

Comments

@dev-pobo
Copy link

Hello, thanks for the library.

I want to invoke the command of unknown cluster, for example:
The matter bridge enable the function of scanning subdevices.

Here's what I think:

  1. Can command-by-id be implemented? For example:
    ./chip-tool any command-by-id 0x130DFC00 0x02 '{"0": 180}' 1 0

  2. After the device is added, Unknown cluster is automatically generated for easy invocation.

@Apollon77
Copy link
Collaborator

Hi, ok what exactly is your usecase?
Do you need this in the matter.js shell ? Yes there this option is missing.
I had the idea of "Dynamic commandline building" also but here yargs seems to do some caching so this might not work or I need to find out how to workaround this cache and make this more device specific ... So maybe that's "harder" to implement then the "by id" command

Or do you need this in controller code? Because there it is already existing and can be used.

So please be more specific what exactly you need and for which usecase.

@Apollon77 Apollon77 added the enhancement New feature or request label Jul 27, 2024
@dev-pobo
Copy link
Author

The Matter.js shell is designed to facilitate testing devices.

Finally, it is necessary to use the controller code to achieve, convenient to give a sample code? We couldn't find the code.

In addition, I found that reading the power consumption/power of a zigbee smart plug, the value is always 0. I don't know why.

Thank you

Screenshot 2024-07-28 at 8 47 00 PM Screenshot 2024-07-28 at 8 53 54 PM Screenshot 2024-07-28 at 9 04 54 PM

@Apollon77
Copy link
Collaborator

Ok I looked into the code.
Currently the cluster clients have support for unknown attributes and event, but not for unknown commands at all, so we need to add this. I adjusted the issue name.
So the workaround for now would be to create a schema definition for the custom cluster and register this, because then it would be no "unknown" cluster anymore :-) Do you have all details for that? Else you need to wait for the above feature to be added. Would be needed to be a file like https://github.com/project-chip/matter.js/blob/main/packages/matter.js/src/cluster/definitions/OnOffCluster.ts

In general: In Controller code when you see in log that a custom cluster was added or custom attributes these are available as objects too. You could create a matter.js schema for the relevant clusters and register this then you could use it in controller code with all the typing and also tlv parsing convenience. as all the other clusters have. This is for cases where you know the structure f the cluster. For cases where this is not the case we do the best to parse the data generically. basically use ´pairedNode.getDeviceById(2)or such to get the relevant endpoint. then usedevice.getClusterClientById(0x123345). On this object you have Attribute client objects like client.unknownAttribute_0x1234` (with the hex number of the attribute id) and same-ish for events.

Re: the question why the attribute value is always 0 can be one of two cases depending on how you connected to the node in the shell
1.) if you connected with an subscription (most likely "nodes connect 111 X Y") then the system currently expects that the values are also updated via subscription and reads are executed locally. We might need to adjust this behavior anyway with Matter 1.4, but right now it is that way. I think there is no way right now in shell to define that the values are requested always remotely. I can also consider as enhancement.
2.) If you connected without subscription (so connect call without X and Y) then the read is done remotely and then this is the response from the device. Debug log would show whats up there.

And please consider posting logs and screen infos as text and not image for copy&paste convenience. Thank you.

@Apollon77 Apollon77 changed the title Unknown cluster invokes the command. Add Unknown command support for ClusterClients (API and shell) Jul 29, 2024
@Apollon77
Copy link
Collaborator

PS: In general a full debug log of that would be interesting because also the warnings about attribute updates received for an unknown endpoint but after this you can interact with this endpoint is weird. So a full debug log of a connect and also a "nodes log" for this node would be interesting. Thank you.-

@dev-pobo
Copy link
Author

For the debug log, please see the attached document.
console.txt
logfile.txt

@Apollon77
Copy link
Collaborator

Thank you, in fact the connection is done with a subscription, so basically it reads locally because it expects attributes to be reported.

You can try to connect without a subscription (kind of with just "nodes connect 111") then it should just do a read* atthe beginning and all reads will be done remotely. Does that values change then?

@dev-pobo
Copy link
Author

Thank you, I will try this method tomorrow

@Apollon77
Copy link
Collaborator

BTW: I also considered this with Eve energy and their custom cluster. Also there energy values are not reported on subscribe which is meehh because you need to poll it which is bad in my eyes :( maybe it changes then with the official Energy cluster soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Planned
Development

No branches or pull requests

2 participants