SiliconLabs / arduino

Arduino Core for Silicon Labs devices
76 stars 15 forks source link

Difficulty Integrating Multiple Switches with Different Press Types in Matter #66

Open tiziano149 opened 2 months ago

tiziano149 commented 2 months ago

Hardware

Arduino Nano Mater

Core version

2.0.0

Arduino IDE version

2.3.2

Operating system

Mac os Sonoma

Radio stack variant

Matter

OpenThread Border Router device (if using Matter)

No response

Issue description

I’m working on a project using the Arduino Nano Matter board with the Matter 2.0.0 library. My goal is to integrate four switches into a single accessory in Apple HomeKit. Each switch should support different press types, including short press, long press, and multi-press.

I’m encountering challenges where each switch appears as a separate device, and I’m struggling to implement the various press types using the MatterSwitch class. Methods like report_event or triggerEvent don’t seem to be available.

I would appreciate any guidance or examples on how to consolidate these switches into one accessory and properly handle different button press types within the existing library framework. Thank you for any assistance you can provide!

Serial output

No response

RTT output (if using Matter)

No response

Minimal reproducer code

No response

lboue commented 1 month ago

I'd also like to make the same device.

leonardocavagnis commented 6 days ago

The MatterSwitch class doesn't natively support multiple press types such as short, long, and multi-press.

A possible approach could be to use the "Operational State Cluster", where you define a unique state for each switch condition (e.g., long press on switch 1, short press on switch 1, multi-press on switches 1 & 2, etc.). Unfortunately, this cluster is currently not implemented in the core.

image (Matter Application Cluster Specification 1.2)

A quick and dirty solution could be to use one of the "Measurement and Sensing" clusters (such as Humidity, Thermostat, etc.) and assign a numeric value for each state. I understand this isn’t an elegant solution, but it’s the only workaround that comes to mind. :)