docs/en/matter/ep_fan.rst
######### MatterFan #########
The MatterFan class provides a fan endpoint for Matter networks with speed and mode control. This endpoint implements the Matter fan control standard.
Features:
Use Cases:
Constructor
MatterFan ^^^^^^^^^
Creates a new Matter fan endpoint.
.. code-block:: arduino
MatterFan();
Initialization
begin ^^^^^
Initializes the Matter fan endpoint with optional initial speed, mode, and mode sequence.
.. code-block:: arduino
bool begin(uint8_t percent = 0, FanMode_t fanMode = FAN_MODE_OFF, FanModeSequence_t fanModeSeq = FAN_MODE_SEQ_OFF_HIGH);
percent - Initial speed percentage (0-100, default: 0)fanMode - Initial fan mode (default: FAN_MODE_OFF)fanModeSeq - Fan mode sequence configuration (default: FAN_MODE_SEQ_OFF_HIGH)This function will return true if successful, false otherwise.
end ^^^
Stops processing Matter fan events.
.. code-block:: arduino
void end();
Constants
MAX_SPEED ^^^^^^^^^
Maximum speed value (100%).
.. code-block:: arduino
static const uint8_t MAX_SPEED = 100;
MIN_SPEED ^^^^^^^^^
Minimum speed value (1%).
.. code-block:: arduino
static const uint8_t MIN_SPEED = 1;
OFF_SPEED ^^^^^^^^^
Speed value when fan is off (0%).
.. code-block:: arduino
static const uint8_t OFF_SPEED = 0;
Fan Modes
FanMode_t ^^^^^^^^^
Fan mode enumeration:
FAN_MODE_OFF - Fan is offFAN_MODE_LOW - Low speedFAN_MODE_MEDIUM - Medium speedFAN_MODE_HIGH - High speedFAN_MODE_ON - Fan is onFAN_MODE_AUTO - Auto modeFAN_MODE_SMART - Smart modeFan Mode Sequences
FanModeSequence_t ^^^^^^^^^^^^^^^^^
Fan mode sequence enumeration:
FAN_MODE_SEQ_OFF_LOW_MED_HIGH - OFF, LOW, MEDIUM, HIGHFAN_MODE_SEQ_OFF_LOW_HIGH - OFF, LOW, HIGHFAN_MODE_SEQ_OFF_LOW_MED_HIGH_AUTO - OFF, LOW, MEDIUM, HIGH, AUTOFAN_MODE_SEQ_OFF_LOW_HIGH_AUTO - OFF, LOW, HIGH, AUTOFAN_MODE_SEQ_OFF_HIGH_AUTO - OFF, HIGH, AUTOFAN_MODE_SEQ_OFF_HIGH - OFF, HIGHOn/Off Control
setOnOff ^^^^^^^^
Sets the on/off state of the fan.
.. code-block:: arduino
bool setOnOff(bool newState, bool performUpdate = true);
newState - New state (true = on, false = off)performUpdate - Perform update after setting (default: true)getOnOff ^^^^^^^^
Gets the current on/off state.
.. code-block:: arduino
bool getOnOff();
toggle ^^^^^^
Toggles the on/off state.
.. code-block:: arduino
bool toggle(bool performUpdate = true);
Speed Control
setSpeedPercent ^^^^^^^^^^^^^^^
Sets the fan speed percentage.
.. code-block:: arduino
bool setSpeedPercent(uint8_t newPercent, bool performUpdate = true);
newPercent - Speed percentage (0-100)performUpdate - Perform update after setting (default: true)getSpeedPercent ^^^^^^^^^^^^^^^
Gets the current speed percentage.
.. code-block:: arduino
uint8_t getSpeedPercent();
Mode Control
setMode ^^^^^^^
Sets the fan mode.
.. code-block:: arduino
bool setMode(FanMode_t newMode, bool performUpdate = true);
newMode - Fan mode to setperformUpdate - Perform update after setting (default: true)getMode ^^^^^^^
Gets the current fan mode.
.. code-block:: arduino
FanMode_t getMode();
getFanModeString ^^^^^^^^^^^^^^^^
Gets a friendly string for the fan mode.
.. code-block:: arduino
static const char *getFanModeString(uint8_t mode);
Event Handling
onChange ^^^^^^^^
Sets a callback for when any parameter changes.
.. code-block:: arduino
void onChange(EndPointCB onChangeCB);
The callback signature is:
.. code-block:: arduino
bool onChangeCallback(FanMode_t newMode, uint8_t newPercent);
onChangeMode ^^^^^^^^^^^^
Sets a callback for mode changes.
.. code-block:: arduino
void onChangeMode(EndPointModeCB onChangeCB);
onChangeSpeedPercent ^^^^^^^^^^^^^^^^^^^^
Sets a callback for speed changes.
.. code-block:: arduino
void onChangeSpeedPercent(EndPointSpeedCB onChangeCB);
updateAccessory ^^^^^^^^^^^^^^^
Updates the physical fan state using current Matter internal state.
.. code-block:: arduino
void updateAccessory();
Operators
uint8_t operator ^^^^^^^^^^^^^^^^
Returns the current speed percentage.
.. code-block:: arduino
operator uint8_t();
Assignment operator ^^^^^^^^^^^^^^^^^^^
Sets the speed percentage.
.. code-block:: arduino
void operator=(uint8_t speedPercent);
Fan Control
.. literalinclude:: ../../../libraries/Matter/examples/MatterFan/MatterFan.ino :language: arduino