docs/en/matter/ep_generic_switch.rst
################### MatterGenericSwitch ###################
The MatterGenericSwitch class provides a generic switch endpoint for Matter networks. This endpoint works as a smart button that can send click events to the Matter controller, enabling automation triggers.
Features:
Use Cases:
Constructor
MatterGenericSwitch ^^^^^^^^^^^^^^^^^^^
Creates a new Matter generic switch endpoint.
.. code-block:: arduino
MatterGenericSwitch();
Initialization
begin ^^^^^
Initializes the Matter generic switch endpoint.
.. code-block:: arduino
bool begin();
This function will return true if successful, false otherwise.
end ^^^
Stops processing Matter switch events.
.. code-block:: arduino
void end();
Event Generation
click ^^^^^
Sends a click event to the Matter controller.
.. code-block:: arduino
void click();
This function sends a click event that can be used to trigger automations in smart home apps. The event is sent immediately and the Matter controller will receive it.
Usage Example:
When a physical button is pressed and released, call this function to send the click event:
.. code-block:: arduino
if (buttonReleased) {
mySwitch.click();
Serial.println("Click event sent to Matter controller");
}
Generic Switch (Smart Button)
.. literalinclude:: ../../../libraries/Matter/examples/MatterSmartButton/MatterSmartButton.ino :language: arduino