-
|
Hello, I'm developing an MQTT to Matter bridge for a window covering (roller shutter) using @matter/main. As a quick disclaimer, I've been writing this code with the assistance of an AI (Google's Gemini). I am not deeply familiar with the @matter/main library myself, so it's possible my attempts to debug the issue are based on incorrect assumptions about the library's API. This is precisely why I'm reaching out for expert help. While I was able to create a stable and functional bridge by using DimmableLightDevice as a workaround, I've been unable to correctly initialize an endpoint using the proper WindowCoveringDevice. I'm sharing both the working code and the problematic code, hoping for some insight into what might be going wrong with the WindowCoveringDevice initialization. The Core Issue When creating an endpoint with new Endpoint(WindowCoveringDevice, ...), the mandatory WindowCovering cluster is not being added to the endpoint's behaviors. The startup logs confirm this, showing only behaviors: ✓identify ✓descriptor and missing ✓windowCovering. This leads to TypeError: Cannot read properties of undefined whenever I try to access endpoint.state.windowCovering or endpoint.events.windowCovering, as the behavior is undefined. My attempts to solve this, including explicitly adding the cluster with endpoint.addClusterServer() or defining features in the endpoint options, have all failed with various errors, suggesting a deeper issue or a non-obvious configuration step specific to WindowCoveringDevice. ✅ Working Workaround using DimmableLightDevice This code successfully bridges the shutter by mapping its 0-100% position to a dimmer's 0-100% level. It initializes correctly and is fully functional. ❌ Non-Working Attempt with WindowCoveringDevice This version represents the most advanced attempt to use the correct device class. It fails because the WindowCovering behavior is never added to the endpoint, causing endpoint.events.windowCovering to be undefined. Console Output & Error Log Here is the console output when running one of the failing attempts. Note the crucial line where the endpoint is created without the ✓windowCovering behavior, which directly leads to the subsequent TypeError. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
yes it is not automatically added because it can not be added in a valid state because you need to define the features. so you need to do it like in the example and define the WindowCovering cluster server with the proper featureset you need. Please refer to the example code provided in https://github.com/matter-js/matter/blob/a2e46fd914025c69cc2ebe856945bcae5391cb01/packages/examples/src/device-composed-wc-light/IlluminatedRollerShade.ts#L19 and https://github.com/matter-js/matter/blob/a2e46fd914025c69cc2ebe856945bcae5391cb01/packages/examples/src/device-composed-wc-light/IlluminatedRollerShade.ts#L78 On one side i hoestly love AI development work, on the other side this clearly shows that a "user" that want to develop something with an AI should still understand the library he uses because the AI is just as smart as the information it has at habd eand you can not rely on an AI knowing each library |
Beta Was this translation helpful? Give feedback.
yes it is not automatically added because it can not be added in a valid state because you need to define the features. so you need to do it like in the example and define the WindowCovering cluster server with the proper featureset you need. Please refer to the example code provided in https://github.com/matter-js/matter/blob/a2e46fd914025c69cc2ebe856945bcae5391cb01/packages/examples/src/device-composed-wc-light/IlluminatedRollerShade.ts#L19 and https://github.com/matter-js/matter/blob/a2e46fd914025c69cc2ebe856945bcae5391cb01/packages/examples/src/device-composed-wc-light/IlluminatedRollerShade.ts#L78
On one side i hoestly love AI development work, on the other side this clearly shows th…