project-chip / connectedhomeip

Matter (formerly Project CHIP) creates more connections between more objects, simplifying development for manufacturers and increasing compatibility for consumers, guided by the Connectivity Standards Alliance.
https://buildwithmatter.com
Apache License 2.0
7.23k stars 1.92k forks source link

[Feature] XML Device Types define Endpoint Composition #32941

Open paulr34 opened 3 months ago

paulr34 commented 3 months ago

Feature description

ZAP utilizes the data model XML and has recently incorporated support for Parent Endpoints.

For ZAP to store Endpoint Composition into the database, it requires the Endpoint Composition to be specified in the Device Type XML.

For instance, the XML should accurately represent the specifications regarding Endpoint Composition. Notably, the current XML lacks any mention of the Temperature Controlled Cabinet being mandatory for a Refrigerator Device Type.

Screenshot 2024-03-05 at 11 15 38 AM

Referencing the "old XML" here and the "new XML" here, it's evident that we need the Device Type to be defined as either "Tree" or "FullFamily" if the Device Type includes Endpoint Composition.

Platform

all

Platform Version(s)

No response

Anything else?

No response

bzbarsky-apple commented 3 months ago

If you tell us what format ZAP can ingest here, we can try to add the relevant bits to the XML.

paulr34 commented 3 months ago

@bzbarsky-apple it makes sense based on previous discussion to do something like following:

Example 1

<endpointComposition>
         <type>fullFamily</type>
         <endpoint>
                    <deviceType> name of device type </deviceType>
         </endpoint>
</endpointComposition>

OR

Example 2

<endpointComposition>
         <endpoint>
                    <deviceType> name of device type </deviceType>
         </endpoint>
         <endpoint>
                    <deviceType> name of device type </deviceType>
         </endpoint>
</endpointComposition>

ZAP can parse the XML in this case and know

  1. This Device Type has Endpoint Composition
  2. This Device Type is fullFamily or not by the "type"
  3. If the "type" is not "fullFamily" then it is "tree" like in Example 2

Alternatively we could put "type" for tree as well like:

Example 3

<endpointComposition>
         <type> tree </type>
         <endpoint>
                    <deviceType> name of device type </deviceType>
         </endpoint>
         <endpoint>
                    <deviceType> name of device type </deviceType>
         </endpoint>
</endpointComposition>

I might be out of date or missing some context, but If something along these lines is added to the XML, ZAP can parse and add to the database per Device Type

bzbarsky-apple commented 3 months ago

That all seems fine; how do you want to handle child endpoints that must be present vs child endpoints that are allowed to be present but not required?

And do we want name of device type, or id?

paulr34 commented 3 months ago

It makes sense to assign an attribute to an endpoint XML tag to indicate whether it's optional. In the example below, the first endpoint is marked as mandatory (true), while the second one is not (false), making it optional. Despite not being mandatory, the presence of the second endpoint in the table implies that it's allowed.

Something along these lines makes sense to me:

<endpointComposition>
         <endpoint mandatory=true>
                    <deviceType> name of device type </deviceType>
         </endpoint>
         <endpoint mandatory=false>
                    <deviceType> name of device type </deviceType>
         </endpoint>
</endpointComposition>
paulr34 commented 3 months ago

Regarding Device Type or Id, from a ZAP perspective either could work but let me double check and get back to you tomorrow.

paulr34 commented 3 months ago

It makes most sense for ZAP to consume the Device Type ID rather than the name

paulr34 commented 3 months ago
<endpointComposition>
         <endpoint mandatory=true>
                   <deviceId> device type ID </deviceId>
         </endpoint>
         <endpoint mandatory=false>
                    <deviceId> device type ID </deviceId>
         </endpoint>
</endpointComposition>
bzbarsky-apple commented 3 months ago

That seems pretty reasonable.