Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Momentary switch device example #11

Closed
lboue opened this issue Feb 5, 2024 · 12 comments
Closed

[Feature request] Momentary switch device example #11

lboue opened this issue Feb 5, 2024 · 12 comments
Assignees

Comments

@lboue
Copy link

lboue commented Feb 5, 2024

Hello,

Switches are not supported in Apple Home. Could you add Generic Switch device example?

Regards

@silabs-bozont silabs-bozont self-assigned this Feb 5, 2024
@silabs-bozont
Copy link
Collaborator

Hello Iboue,
Unfortunately switches are currently not supported by the major ecosystems including Apple Home. That's why the example has been left out. Once Switch support becomes available we will definitely include an example for it. The Switch class is available to experiment with, so if you have a Matter hub that supports it you can use it at your own risk :)

In the meantime if you want to achieve similar functionality - you can control your lightbulb's on/off state with a physical switch and sync the state to the Matter network, but it won't be able to control other devices in the same group as a regular Matter Switch would. There will also be an example for this in the future.

@lboue
Copy link
Author

lboue commented Feb 7, 2024

I have the Philips Hue bridge with is exposing Hue Dimmer Switch via Matter protocol, so I it possible to expose Momentary switch.

It works with Apple Home:
matter_dimmer

@lboue
Copy link
Author

lboue commented Feb 7, 2024

Here's a sample implementation: esp-matter Generic Switch.
This example creates a Generic Switch device using the ESP Matter data model

@lboue lboue changed the title Generic Switch device example Momentary switch device example Feb 7, 2024
@lboue
Copy link
Author

lboue commented Feb 7, 2024

I have the Philips Hue bridge with is exposing Hue Dimmer Switch via Matter protocol, so I it possible to expose Momentary switch.

Here is the device exposed to Matter fabric by Hue bridge:

{
   "7/29/0":[
      {
         "deviceType":17,
         "revision":1
      },
      {
         "deviceType":19,
         "revision":1
      }
   ],
   "7/29/1":[
      29,
      57,
      47,
      46
   ],
   "7/29/2":[
      
   ],
   "7/29/3":[
      8,
      9,
      10,
      11
   ],
   "7/29/65532":0,
   "7/29/65533":1,
   "7/29/65528":[
      
   ],
   "7/29/65529":[
      
   ],
   "7/29/65531":[
      0,
      1,
      2,
      3,
      65528,
      65529,
      65531,
      65532,
      65533
   ],
   "7/57/5":"Hue dimmer salon",
   "7/57/17":true,
   "7/57/2":4107,
   "7/57/1":"Signify Netherlands B.V.",
   "7/57/3":"RWL021",
   "7/57/10":"1.1.28573",
   "7/57/18":"115dc69142c249e1a217447262f98823",
   "7/57/14":"Hue dimmer switch",
   "7/57/65532":0,
   "7/57/65533":1,
   "7/57/65528":[
      
   ],
   "7/57/65529":[
      
   ],
   "7/57/65531":[
      5,
      17,
      2,
      1,
      3,
      10,
      18,
      14,
      65528,
      65529,
      65531,
      65532,
      65533
   ],
   "7/47/14":0,
   "7/47/1":1,
   "7/47/0":1,
   "7/47/2":"Primary Battery",
   "7/47/25":3,
   "7/47/15":false,
   "7/47/16":2,
   "7/47/19":"Unspecified",
   "7/47/65532":10,
   "7/47/65533":1,
   "7/47/65528":[
      
   ],
   "7/47/65529":[
      
   ],
   "7/47/65531":[
      14,
      1,
      0,
      2,
      25,
      15,
      16,
      19,
      65528,
      65529,
      65531,
      65532,
      65533
   ],
   "7/46/0":[
      7
   ],
   "7/46/65532":0,
   "7/46/65533":1,
   "7/46/65528":[
      
   ],
   "7/46/65529":[
      
   ],
   "7/46/65531":[
      0,
      65528,
      65529,
      65531,
      65532,
      65533
   ]
}

@lboue
Copy link
Author

lboue commented Feb 7, 2024

Hello Iboue, Unfortunately switches are currently not supported by the major ecosystems including Apple Home. That's why the example has been left out. Once Switch support becomes available we will definitely include an example for it. The Switch class is available to experiment with, so if you have a Matter hub that supports it you can use it at your own risk :)

There is 2 generic-switch certified products:

  1. Tuo Smart Button by TUO Accessories
  2. Kasa Matter Smart Dimmer Switch by Kasa

@silabs-bozont
Copy link
Collaborator

Thanks for the information - Button support now seems to be more widely available! I'll look into this and if possible we'll make the Switch examples available in the next release.

@lboue
Copy link
Author

lboue commented Feb 10, 2024

I also found this tutorial from SL : Matter over OpenThread Multi-feature Button

Overview

This tutorial will show you how to create and build a general Matter switch app that can trigger multiple types of events using a single button. This is based on the Silicon Labs Matter Github (SMG) repository's existing light-switch app.

For the demonstration purpose, I will use 2 x EFR32xG24 Wireless 2.4 GHz +10 dBm Radio Board (BRD4186C) and EFR32 Wireless Starter Kit (WSTK) Mainboard (BRD4001A), one for the switch and the other for the light. You can use any eligible listed in the hardware required section.

Events that this button can trigger are:

  • Short press
  • Short release
  • Long press
  • Long release
  • Multi press

Step 10: Interaction with the Apple ecosystem

In this demo, I will create a Matter light over Thread device. Ater that, I commission both the switch and the light with an Apple HomePod mini.

First, I compile the Matter light and flash it similar to the switch.
$ ./scripts/examples/gn_efr32_example.sh examples/lighting-app/silabs/efr32/ out/lighting-app BRD4186C "chip_detail_logging=false chip_automation_logging=false"
Then, I commission and bind them as below:

  • Single press action

Image demo

  • Double press action

Image demo

Finally, We can control the lighting device by the single pressing and double pressing the button 1 on the development kit.

@silabs-bozont
Copy link
Collaborator

Thanks for the linked resources! I have good news - Matter Switch support will be coming soon (along with an example) in the next release.

@lboue lboue changed the title Momentary switch device example [Feature request] Momentary switch device example Feb 15, 2024
@lboue
Copy link
Author

lboue commented Feb 15, 2024

Thanks for the linked resources! I have good news - Matter Switch support will be coming soon (along with an example) in the next release.
Nice! Will the new version be released in February?

@silabs-bozont
Copy link
Collaborator

The new version is planned to be released around the 21st of March during Arduino Days to support the new Nano Matter board.

@lboue
Copy link
Author

lboue commented Mar 21, 2024

The new version is planned to be released around the 21st of March during Arduino Days to support the new Nano Matter board.

Could you tell us when will the new version be published?

silabs-build-bot pushed a commit that referenced this issue May 7, 2024
* Update the core package JSON to match the published one

* Add back support for the Arduino Nano Matter

It was removed to be excluded from the first release

* Add back support for the Seeed Studio Wio MG24

It was removed to be excluded from the first release

* Update readme files

- Correct a typo in the Matter readme
- Emphasize the different bootloaders in the main readme

* Add details about the Google Home Developer Console setup to the Matter readme

* Implement multi-instance support in the I2C driver

* Add a second I2C instance on the xG24 Explorer Kit

Now the QWIIC connector can also be used

* Make the SPI peripheral configurable in ezWS2812

* Add a note to the readme about the 1.x version IDEs not being supported

* Update the Matter library readme

Add documentation for the global Matter class.
Mention the addtitonal Matter Hub device.

* Bump the version of ezWS2812 to 1.1

* Update the repo URL in the included libraries

* Update the install host and packager scripts to host the next development version

* Update the GSDK generator script to use the newest SDK versions

GSDK 4.4.0
Matter 2.2.0

* Upgrade GSDK on the ThingPlus Matter BLE variant to 4.4.0

* Upgrade GSDK on the ThingPlus Matter BLE precomp variant to 4.4.0

* Update the GSDK generator script to work with the Matter SDK 2.2.0

Changed path for the ZAP file
Removed the color endpoint number patching - issue solved in SDK
Added device name and manufacturer patching as these have moved

* Upgrade GSDK and Matter SDK on the ThingPlus Matter (Matter) precomp variant

Upgraded to GSDK 4.4.0 and Matter SDK 2.2.0

* Upgrade GSDK and Matter SDK on the ThingPlus Matter (Matter) variant

Upgraded to GSDK 4.4.0 and Matter SDK 2.2.0

* Fix starting state sync in the Matter color multiple bulb example

* Fix the capitalization of 'LED' in the readme

* Upgrade GSDK on the BGM220 Explorer Kit BLE variant to 4.4.0

* Upgrade GSDK on the BGM220 Explorer Kit BLE precomp variant to 4.4.0

* Upgrade GSDK on the xG24 Explorer Kit BLE variant to 4.4.0

* Upgrade GSDK on the xG24 Explorer Kit BLE precomp variant to 4.4.0

* Upgrade GSDK and Matter SDK on the xG24 EK (Matter) precomp variant

Upgraded to GSDK 4.4.0 and Matter SDK 2.2.0

* Upgrade GSDK and Matter SDK on the xG24 EK (Matter) variant

Upgraded to GSDK 4.4.0 and Matter SDK 2.2.0

* Upgrade GSDK on the xG27 Dev Kit variants to 4.4.0

* Upgrade GSDK on the Seeed Studio Wio MG24 variants to 4.4.0

* Upgrade GSDK on the Arduino Nano Matter BLE variants to 4.4.0

* Upgrade GSDK and Matter SDK on the Arduino Nano Matter (Matter) variants

Upgraded to GSDK 4.4.0 and Matter SDK 2.2.0

* Use GPIO input in pullup configuration in the BLE Blinky example

* Update the Matter lightbulb brightness percentage calculation to be precise

Mapping between the true range and percents had some rounding errors

* Correct typo in readme

* Add BLE and platform support for the xG24 Dev Kit (brd2601b)

Implements #11

* Add a precompiled BLE variant for the xG24 Dev Kit (brd2601b)

Implements #11

* Update docs with the xG24 Dev Kit support

Implements #11

* Add the xG24 Dev Kit to the build test script

Implements #11

* Add Matter support for the xG24 Dev Kit

Implements #12

* Add a precompiled Matter variant for the xG24 Dev Kit

Implements #12

* Add the xG24 Dev Kit Matter variants to the build test script

Also add the xG24 Dev Kit variants to the distinct categories
Implements #12

* Update list of compatible devices in the Matter examples

Implements #12

* Migrate the Si7210 driver library from Bitbucket

Implements #15

* Migrate the PDM driver library from Bitbucket

Implements #15

* Migrate the xG27 Dev Kit sensors example from Bitbucket

Implements #15

* Migrate the BLE HID keyboard example from Bitbucket

Implements #15

* Refactor the BLE HID keyboard example

Implements #15

* Refactor the xG27 Dev Kit sensors example

Implements #15

* Refactor the PDM microphone driver library

Implements #15

* Migrate the xG27 Dev Kit sensors BLE example from Bitbucket

Implements #15

* Refactor the xG27 Dev Kit sensors BLE example

Implements #15

* Migrate the ThingPlus battery gauge example from Bitbucket

Implements #15

* Implement a BLE battery level example for the ThingPlus Matter

Implements #15

* Refactor the build test script, add new examples

Implements #15

* Update example compatibility lists, correct a few typos

* Update the board specific defines for the Nano Matter

Remove the ARDUINO_ prefix as it's added by platform.txt afterwards

* Invert button state and improve LED handling in the BLE Blinky example

* Rename the Si7210Hall library to Si7210_hall

* Update the examples using Si7210 with the new name

* Refactor the Si7210_hall library

 - Refactor the included example
 - Fix I2C wake-up (previously the wake-up signal didn't go out)
 - Take the bus driver as a reference instead of a pointer
 - Define the default I2C address and speed
 - Add a constructor without parameters
 - Use initializer lists

* Update the test build script to be able to build smaller subsets

* Update Simplicity Commander to 1.16.4

Implements #33

* Implement helper script for calculating file size and checksum

Implements #33

* Repackage the new Simplicity Commander archives with zstd

The macOS archive was kept as a zip as macOS had problems with the
app signing after deflating the zstd archive.
Implements #33 #5

* Add CMSIS-pack for MGM240SD22VNA

* Nano Matter: add USB PID and upload pack

* toolchain: make path installation independent

* pyocd: fix wrong commandline on verbose params

* Implement support for the BridgedDeviceBasicInformation Matter cluster

This gives the users the option to customize their devices
Implements #41

* Bump the Matter library version to 1.1

* Fix the Si7210 library path in the build test script

* Remove unused Matter device classes

* Refactor the MatterDevice base class

* Add the new Matter example to the build test script

Also implement a SIGINT handler

* Fix the debugger path in platform.txt

* Move cluster read/write functions to the specific Matter classes

This is a major refactor - each device class is now responsible for
handling the read/write of their associated clusters. The read/write
functions are virtual and inherited from the base device class.

* Bump the year in the Matter library source files

* Move the Matter change reporting to each device class

Major refactor - each device class is now responsible for sending
the Matter change report after their own status/values change.
Now each device class encapsulates the whole functionality
of the device - no external callbacks or functions needed.

* Add GitHub issue template

* Rename the Silicon Labs example library

* Implement support for Matter Contact Sensor

Implements #45

* Update readme.md

 - Mark BLE and Matter variants
 - Separate the ezBLE readme
 - Add the Nano Matter to relevant sections

* Change the capitalization of getCPUTemp()

* Rename the device unique ID getters

* Update the Matter readme

 - Add unpairing instructions
 - Move the device property setters to the correct section

* Enable Matter Switch support and add switch example

Implements #42

* Avoid calling the Matter API from ISR context in examples

* Implement the 'Matter lightbulb with button' example

Implements #17

* Update J-Link debugging to work with the newer 2.3.x IDEs

Fixes #43

* Update the year in the SparkFun Thing Plus BLE GSDK generated files

* Make the ThingPlus BLE variants use the same bootloader as Matter

This way the bootloader won't have to be reflashed when changing
between Matter and BLE, so we avoid a massive pitfall for the users.

* Update the year in the xG24 Explorer Kit BLE GSDK generated files

* Make the xG24 Explorer Kit BLE variants use the same bootloader as Matter

* Make the xG24 Dev Kit BLE variants use the same bootloader as Matter

* Update the year in the Nano Matter BLE GSDK generated files

* Make the Nano Matter BLE variants use the same bootloader as Matter

* Update the year in the BGM220 Explorer Kit BLE GSDK generated files

* Make the BGM220 Explorer Kit use a storage-internal bootloader

This is to consistently use the same bootloader on all the variants

* Update the year in the xG27 Dev Kit BLE GSDK generated files

* Make the xG27 Dev Kit use a storage-internal bootloader

* Update the year in the Wio MG24 BLE GSDK generated files

* Make the Wio MG24 use a storage-internal bootloader

* Update readme files to reflect the unified bootloaders

* Fix the programmer highlighting in readme

* Prevent GPIO use before the system initialization finished

Calling any GPIO function before the system init finishes
causes a fault because the GPIO clocks are not enabled yet.
Any calls to GPIO functions will now have no effect
before the init finishes.

* Change the package format of the core and compiler to zstd

Implements #5

* Use OpenOCD as upload tool for the Nano Matter

* Add the OpenOCD package to the package index JSON

* Fix the OpenOCD bootloader burning command

'_' vs '-' in the interface config file path

* Add erasing support for the OpenOCD programmer

* Remove pyOCD support

OpenOCD will be used instead

* Increase the version in platform.txt to 1.1.0

* Add missing mathematical constants

* Add the Arduino-like pin definitions for the Nano Matter

* Add pinout diagram for the BGM220 Explorer Kit

Implements #16

* Add pinout diagram for the xG24 Dev Kit

* Remove the placeholder timer instance from main()

It's no longer needed to keep the uptime ticks counting

* Make millis() more precise

Using the internal conversion function we get full resolution

* Fix OpenOCD programming on Windows

A couple of extra curly braces were needed
Fixes #53

* Add verbose and quiet options to OpenOCD

* Add language specific highlighting to readme and issue_template

* Create a BLE/Matter combined variant for the Nano Matter

This variant doesn1t include the SDK sources only the precompiled
SDK is available

* Remove the old variant files of the Nano Matter

* Create a BLE/Matter combined variant for the Thing Plus Matter

* Remove the old variant files of the Thing Plus Matter

* Create a BLE/Matter combined variant for the xG24 Explorer Kit

* Remove the old variant files of the xG24 Explorer Kit

* Create a BLE/Matter combined variant for the xG24 Dev Kit

* Remove the old variant files of the xG24 Dev Kit

* Create a combined BLE variant for the xG27 Dev Kit

* Remove the old variant files of the xG27 Dev Kit

* Create a combined BLE variant for the Seeed Studio Wio MG24

* Remove the old variant files of the Seeed Studio Wio MG24

* Create a combined BLE variant for the BGM220 Explorer Kit

* Remove the old variant files of the BGM220 Explorer Kit

* Rearrange boards.txt, move the Wio MG24 up to the third-party boards

* Remove the hard button requirement from the BLE lightswitch client example

* Update the build test script to work with the new variant scheme

* Update readme to reflect the variant changes

* Update readme wording to include the Settings/Preferences for all platforms

macOS - Settings
Windows / Linux - Preferences

* Disable SWO and RAIL PTI by default

These take up precious GPIO, so they have to be off by default.
Users can reenable them if needed.
Fixes #55

* Fix the initial state in pulseIn()

pulseIn() should wait for the requested state and measure
the time elapsed until the opposite of the requested state
Fixes #57

* Add guard to host_local_install.py to ensure running from the 'package' directory

* Simplify organization of the board support slcp files

* Add a 'no radio' variant for the BGM220 Explorer Kit

* Add a 'no radio' variant for the Nano Matter

* Add a 'no radio' variant for the Sparkfun Thing Plus Matter

* Add a 'no radio' variant for the Seeed Studio Wio MG24

* Add a 'no radio' variant for the xG27 Dev Kit

* Add a 'no radio' variant for the xG24 Explorer Kit

* Add a 'no radio' variant for the xG24 Dev Kit

* Move the configurations down in the GSDK generator script

* Update readme.md with more radio stack information

* Handle active low/high built-in LED configurations simultaneously

* Correct typo in ezBLE

* Change issue template to the new format

* Update the title and labels in the new issue templates

* Implement function to check whether a Matter device is online

Online in this context means that it has been discovered by the Matter hub
and is able to communicate with it.

* Update the year in the Thing Plus Matter generated files

* Regenerate GSDK and Matter SDK for the Nano Matter (Matter)

We use our own Window Covering server implementation, so
the included one was removed.
Window Covering cluster commands were added to the ZAP file.

* Regenerate GSDK and Matter SDK for the xG24 Explorer Kit (Matter)

We use our own Window Covering server implementation, so
the included one was removed.
Window Covering cluster commands were added to the ZAP file.

* Regenerate GSDK and Matter SDK for the xG24 Dev Kit (Matter)

We use our own Window Covering server implementation, so
the included one was removed.
Window Covering cluster commands were added to the ZAP file.

* Add support for Matter Window Covering

Implements #21

* Regenerate GSDK and Matter SDK for the ThingPlus Matter (Matter)

We use our own Window Covering server implementation, so
the included one was removed.
Window Covering cluster commands were added to the ZAP file.

* Rework pin mapping to be Arduino-like

Implements #9 #59

* Offset PinName to avoid overlap with pin indexes

This way if a PinName is implicitly converted to pin_size_t
it can be distinguised and handled accordingly.
This offers more compatibility between the different pin mappings.

* Update the pinout diagrams with the new pin names

* Rework ADC to work with the new pin mapping scheme

* Mark all DAC pins on the pinout diagrams and pin maps

* Add a new I2C and remap SPI1 on the Nano Matter

* Increase number of max LEDs in ezWS2812

Use uint32_t instead of uint8_t

* Add interrupt lock/unlock to ezWS2812 examples

In the future these will have to be moved inside the driver

* Update readme with instructions for 'discussions'

* Properly escape paths in boards.txt and platform.txt

Fixes #75

* Add specific exit codes to the build test script

This will help when running the script from CI

* debugger: implement new interface

* Make OpenOCD debugging Nano Matter specific, update readme

* Bump the Matter Color Control cluster revision from 5 to 6

* Set the Matter Level Control cluster max values to 254

According to the specification this is the maximum allowed value

* Bump the Matter Basic Information cluster revision to 2

* Remove the Matter Identify cluster from the Aggregator endpoint

* Implement support for the Matter Identify cluster

Right now only the lightbulbs use it, but it can be easily
extended to support all available endpoints.

* Regenerate GSDK and Matter SDK for all Matter variants

* Add missing cluster attributes to Matter On/Off lightbulbs

* Change the Matter Vendor ID and Name according to each board

* Change the board number of the Nano Matter to brd2707a

brd9050 was already taken - brd2707 was assigned instead

* Add OpenThread RCP firmware image for the Nano Matter

* Fix Matter onboarding QR code to include provisioned data

By a known issue the regular GetQRCode() function always uses the
default set-up pin even when it's changed,
reulting in an uncommissionable device. This new method extracts the
onboarding payload and generates the QR from that - and it now includes
the changed PIN - so it can be used for onboarding.

* Implement compiler warning monitoring in the build test script

* Implement support for Matter On/Off Plug-in Unit / Outlet

Implements #83

* Add toggle functionality to the Matter Lightbulb

* Remove the Seeed Studio Wio MG24 variant

The board won't be released soon - we can add
it back later if it comes out.

* Implement support for Matter Air Quality sensor

* initial: add core-api

* add Serial refactoring

* add ArduinoCore-API as a submodule

* move core api in 'extra' folder

* Serial extern refinement

* fix wiring management

* using namespace in Wire lib

* create Interrupt and Tone files

* add missing Silicon Labs MIT license

* fix attachInterrupt prototype issue and remove unused stuff

* cosmetics (uncrustify)

* SPI library refactoring

* externalization of Wire and SPI libraries

* suppressing unused param warnings

* fix compilation issue in ezBLE and ezWS2812 lib

* fix random function prototypes

* add api folder in the include path

* Remove the default value from 'block' in SPI.transfer()

This resolves the ambiguity with the base class.
Also, change the default transfer type to blocking.

* Add the Matter Air Quality sensor example to the build test script

* Add missing newlines in MatterOnOffPluginUnit

* Update the core packager script to include the Core-API

* Update the readme with instructions for using the Core-API

* Update the product link for the Nano Matter in the readme

* Bump the core version to 2.0.0

* Reword the Matter compatibility warning message

* Fix the Nano Matter color lightbulb example and add it to the tests

* Corrections in the global and Matter readme

* Update the 'made with' section in the readme

* Fix the signature of delayMicroseconds()

* Fix the signature of the shift functions

Also add more core function calls to the test sketch

* Fix 'pin_name_clock' paramteter passing in shiftIn()

* Add more SPI and Wire calls to the test sketch

* Bump the Matter library version to 2.0.0 to be in sync with the core

* Add pin definitions for all Serial/Wire/SPI peripherals

* Fix DAC initialization, add missing DAC instances

Output pin is now explicitly initialized to 'gpioModeWiredOr'

---------

Co-authored-by: Martino Facchin <m.facchin@arduino.cc>
Co-authored-by: Hai Nguyen <hanguyen2@silabs.com>
Co-authored-by: Leonardo Cavagnis <l.cavagnis@arduino.cc>
@silabs-bozont
Copy link
Collaborator

Available now in 2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants