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.49k stars 2.01k forks source link

Using cluster inspection to extend endpoint capability is a path to madness #36403

Closed jonsmirl closed 1 week ago

jonsmirl commented 1 week ago

@bzbarsky-apple

Feature description

Problem description: My product is a light switch which has a built in LED to indicate the status of the switch. I created a standard LightSwitch endpoint which was marked with the LightSwitch device type. I then extended the standard endpoint by adding a LevelControl cluster representing my LED. I marked this extension by adding a VendorDeviceType. I was careful to do my extension in such a way that it in no way impacted the functions required by the standard LightSwitch device type. My extension is a pure super set.

When I added this device to Apple Home I observed a completely unexpected behavior. Apple Home added the Light Switch but then it performed cluster inspection and also added a Light Bulb device. image

Impacts: Using cluster inspection to extend endpoint capability is a backdoor way to extend the spec and it should be prohibited by the spec. Due to Apple Home performing cluster inspection I have now lost any ability to create vendor specific super sets of a device type. I lose this ability because I have no mechanism to disable Apple Home's cluster inspection. Also consider what is going to happen if the spec adds indicator LEDs to the Light Switch specification. Apple's creation of this UI disrupts how an indicator LED would work (the LED should not have a UI, instead it is bound to the switch group so that it tracks the state of the group). But now, because of Apple Home's cluster inspection, we can't add indicator LEDs to the Light Switch type.

Proposed solution:

First, all cluster inspection should be banned. Endpoint capability is determined by the device type(s) and only the device type(s). This is the path to madness, if these extensions are not marked with a vendor device type there is no mechanism to sort out conflicting extensions.

Any extensions to an endpoint MUST be marked by a VendorDeviceType. And these extensions MUST be a pure super set. It MUST still be possible to use the endpoint's base device type and to ignore the vendor extensions. Endpoints like this would list two device types, the base device type and the vendor device type.

Apple Home can still generate this extended UI, however, to trigger it you will need to add an AppleDeviceType on your endpoint in addition to the base device type to indicate that it has the extended capabilities. If that AppleDeviceType isn't there, Apple Home should not go probing for clusters. Note that even though this is an AppleDeviceType any vendor can use it, it is an AppleDeviceType because Apple defined it.

Since Apple Home has already shipped this a legacy solution is needed. I would propose that Apple Home define and document this AppleDeviceType. Newly shipped products would need to include it in the future in order to trigger the UI. For existing products Apple Home should be modified to check for the existence of a VendorDeviceType on the endpoint and if there is a VendorDeviceType it should disable this UI. Using lack of a VendorDeviceType to enable the Apple Home extended behavior is a legacy solution. All future devices should add the AppleDeviceType to trigger this extended UI.

The conformance tests should be modified to enforce this. If an endpoint contains clusters or attributes which are not part of the base device type then it MUST be marked with a vendor device type.

Requiring extensions to be clearly marked and prohibiting cluster inspection will close this backdoor to spec extensions.

Platform

all

Platform Version(s)

No response

Anything else?

No response

andy31415 commented 1 week ago

This issue seems integration-specific rather than SDK specific.

Please follow the instruictions for providing feedback to apple (https://project-chip.github.io/connectedhomeip-doc/issue_triage.html#apple-integration)