espressif / esp-matter

Espressif's SDK for Matter
Apache License 2.0
679 stars 155 forks source link

Creating a Toggle Switch with On/Off Cluster and Binding for Group Control (CON-1256) #1010

Closed mortezaMoezzifar closed 1 month ago

mortezaMoezzifar commented 3 months ago

Summary:

I am working on creating a toggle switch using the On/Off Cluster in Matter that supports binding and group functionality. The goal is to control a single light or a group of lights, with an LED on the switch that reflects the status of the light or group of lights.

Details:

Question:

What is the best method to obtain the status of a light or a group of lights in Matter so that the LED indicator on my toggle switch can accurately reflect the on/off state of the controlled lights?

Relevant Information:

Thank you for your assistance!

jadhavrohit924 commented 3 months ago

@mortezaMoezzifar Please check out light and light_switch where we have showed binding between light and switch. You can just group the lights and use the same switch to control it.

jonsmirl commented 3 months ago

@jadhavrohit924 He wants an indicator light in the switch. Think about that and you'll see that it is a much larger problem than it appears. For example, if you group the lights in your app, how do the Apple/Amazon/Google apps control the grouped lights and keep them in sync?

mortezaMoezzifar commented 3 months ago

I have grouped the lights and bound them with a switch. How can I synchronize the LED status on the switch with the group of lights?

I could include the LED on the switch in the group of lights, but it doesn't seem like the correct approach. Are there other methods? I want to know the best practice in Matter.

jadhavrohit924 commented 2 months ago

@mortezaMoezzifar I understand your issue, what you can do is. You subscribe your generic switch to the light and whenever there is a change in your end accessory, the switch will know about it via matter subscription and you can then change the state of your LED on the switch.

jadhavrohit924 commented 2 months ago

@mortezaMoezzifar Have you tried the above suggestions? Please close the issue if it is resolved.

mortezaMoezzifar commented 1 month ago

@jadhavrohit924 i need example code for subscribe on light to update state of led on my light switch

jadhavrohit924 commented 1 month ago

@mortezaMoezzifar Please checkout the code of subscription, here is the reference example