Skip to content

Commit 51d1bd8

Browse files
committed
feat(matter): adds temperature controlled cabinet matter endpoint
1 parent c0395df commit 51d1bd8

File tree

13 files changed

+1840
-0
lines changed

13 files changed

+1840
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ set(ARDUINO_LIBRARY_Matter_SRCS
191191
libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.cpp
192192
libraries/Matter/src/MatterEndpoints/MatterFan.cpp
193193
libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp
194+
libraries/Matter/src/MatterEndpoints/MatterTemperatureControlledCabinet.cpp
194195
libraries/Matter/src/MatterEndpoints/MatterHumiditySensor.cpp
195196
libraries/Matter/src/MatterEndpoints/MatterContactSensor.cpp
196197
libraries/Matter/src/MatterEndpoints/MatterPressureSensor.cpp
Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
#######################################
2+
MatterTemperatureControlledCabinet
3+
#######################################
4+
5+
About
6+
-----
7+
8+
The ``MatterTemperatureControlledCabinet`` class provides a temperature controlled cabinet endpoint for Matter networks. This endpoint implements the Matter temperature control standard for managing temperature setpoints with min/max limits, optional step control, or temperature level support.
9+
10+
**Important:** The ``temperature_number`` and ``temperature_level`` features are **mutually exclusive**. Only one can be enabled at a time. Use ``begin(tempSetpoint, minTemp, maxTemp, step)`` for temperature_number mode or ``begin(supportedLevels, levelCount, selectedLevel)`` for temperature_level mode.
11+
12+
**Features:**
13+
* Two initialization modes:
14+
* **Temperature Number Mode** (``begin(tempSetpoint, minTemp, maxTemp, step)``): Temperature setpoint control with min/max limits and optional step
15+
* **Temperature Level Mode** (``begin(supportedLevels, levelCount, selectedLevel)``): Temperature level control with array of supported levels
16+
* 1/100th degree Celsius precision (for temperature_number mode)
17+
* Min/max temperature limits with validation (temperature_number mode)
18+
* Optional temperature step control (temperature_number mode)
19+
* Temperature level array support (temperature_level mode)
20+
* Automatic setpoint validation against limits
21+
* Feature validation - methods return errors if called with wrong feature mode
22+
* Integration with Apple HomeKit, Amazon Alexa, and Google Home
23+
* Matter standard compliance
24+
25+
**Use Cases:**
26+
* Refrigerators and freezers
27+
* Wine coolers
28+
* Medical storage cabinets
29+
* Laboratory equipment
30+
* Food storage systems
31+
* Temperature-controlled storage units
32+
33+
API Reference
34+
-------------
35+
36+
Constructor
37+
***********
38+
39+
MatterTemperatureControlledCabinet
40+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41+
42+
Creates a new Matter temperature controlled cabinet endpoint.
43+
44+
.. code-block:: arduino
45+
46+
MatterTemperatureControlledCabinet();
47+
48+
Initialization
49+
**************
50+
51+
begin
52+
^^^^^
53+
54+
Initializes the Matter temperature controlled cabinet endpoint with **temperature_number** feature mode. This enables temperature setpoint control with min/max limits and optional step.
55+
56+
**Note:** This mode is mutually exclusive with temperature_level mode. Use ``begin(supportedLevels, levelCount, selectedLevel)`` for temperature level control.
57+
58+
.. code-block:: arduino
59+
60+
bool begin(double tempSetpoint = 0.00, double minTemperature = -10.0, double maxTemperature = 32.0, double step = 0.50);
61+
62+
* ``tempSetpoint`` - Initial temperature setpoint in Celsius (default: 0.00)
63+
* ``minTemperature`` - Minimum allowed temperature in Celsius (default: -10.0)
64+
* ``maxTemperature`` - Maximum allowed temperature in Celsius (default: 32.0)
65+
* ``step`` - Temperature step value in Celsius for step control feature (default: 0.50, disabled if 0)
66+
67+
This function will return ``true`` if successful, ``false`` otherwise.
68+
69+
**Note:** The implementation stores temperature with 1/100th degree Celsius precision internally. If step is greater than 0, the temperature_step feature will be enabled.
70+
71+
begin (overloaded)
72+
^^^^^^^^^^^^^^^^^^
73+
74+
Initializes the Matter temperature controlled cabinet endpoint with **temperature_level** feature mode. This enables temperature level control with an array of supported levels.
75+
76+
**Note:** This mode is mutually exclusive with temperature_number mode. Use ``begin(tempSetpoint, minTemp, maxTemp, step)`` for temperature setpoint control.
77+
78+
.. code-block:: arduino
79+
80+
bool begin(uint8_t *supportedLevels, uint16_t levelCount, uint8_t selectedLevel = 0);
81+
82+
* ``supportedLevels`` - Pointer to array of temperature level values (uint8_t, 0-255)
83+
* ``levelCount`` - Number of levels in the array (maximum: 16)
84+
* ``selectedLevel`` - Initial selected temperature level (default: 0)
85+
86+
This function will return ``true`` if successful, ``false`` otherwise.
87+
88+
**Note:** The maximum number of supported levels is 16 (defined by ``temperature_control::k_max_temp_level_count``). The array is copied internally, so it does not need to remain valid after the function returns. This method uses a custom endpoint implementation that properly supports the temperature_level feature.
89+
90+
end
91+
^^^
92+
93+
Stops processing Matter temperature controlled cabinet events.
94+
95+
.. code-block:: arduino
96+
97+
void end();
98+
99+
Temperature Setpoint Control
100+
****************************
101+
102+
setTemperatureSetpoint
103+
^^^^^^^^^^^^^^^^^^^^^^^
104+
105+
Sets the temperature setpoint value. The setpoint will be validated against min/max limits.
106+
107+
**Requires:** temperature_number feature mode (use ``begin()``)
108+
109+
.. code-block:: arduino
110+
111+
bool setTemperatureSetpoint(double temperature);
112+
113+
* ``temperature`` - Temperature setpoint in Celsius
114+
115+
This function will return ``true`` if successful, ``false`` otherwise (e.g., if temperature is out of range or wrong feature mode).
116+
117+
**Note:** Temperature is stored with 1/100th degree Celsius precision. The setpoint must be within the min/max temperature range. This method will return ``false`` and log an error if called when using temperature_level mode.
118+
119+
getTemperatureSetpoint
120+
^^^^^^^^^^^^^^^^^^^^^^
121+
122+
Gets the current temperature setpoint value.
123+
124+
.. code-block:: arduino
125+
126+
double getTemperatureSetpoint();
127+
128+
This function will return the temperature setpoint in Celsius with 1/100th degree precision.
129+
130+
Min/Max Temperature Control
131+
****************************
132+
133+
setMinTemperature
134+
^^^^^^^^^^^^^^^^^
135+
136+
Sets the minimum allowed temperature.
137+
138+
**Requires:** temperature_number feature mode (use ``begin()``)
139+
140+
.. code-block:: arduino
141+
142+
bool setMinTemperature(double temperature);
143+
144+
* ``temperature`` - Minimum temperature in Celsius
145+
146+
This function will return ``true`` if successful, ``false`` otherwise. Will return ``false`` and log an error if called when using temperature_level mode.
147+
148+
getMinTemperature
149+
^^^^^^^^^^^^^^^^^
150+
151+
Gets the minimum allowed temperature.
152+
153+
.. code-block:: arduino
154+
155+
double getMinTemperature();
156+
157+
This function will return the minimum temperature in Celsius with 1/100th degree precision.
158+
159+
setMaxTemperature
160+
^^^^^^^^^^^^^^^^^
161+
162+
Sets the maximum allowed temperature.
163+
164+
**Requires:** temperature_number feature mode (use ``begin()``)
165+
166+
.. code-block:: arduino
167+
168+
bool setMaxTemperature(double temperature);
169+
170+
* ``temperature`` - Maximum temperature in Celsius
171+
172+
This function will return ``true`` if successful, ``false`` otherwise. Will return ``false`` and log an error if called when using temperature_level mode.
173+
174+
getMaxTemperature
175+
^^^^^^^^^^^^^^^^^
176+
177+
Gets the maximum allowed temperature.
178+
179+
.. code-block:: arduino
180+
181+
double getMaxTemperature();
182+
183+
This function will return the maximum temperature in Celsius with 1/100th degree precision.
184+
185+
Temperature Step Control (Optional)
186+
***********************************
187+
188+
setStep
189+
^^^^^^^
190+
191+
Sets the temperature step value. This enables the temperature_step feature.
192+
193+
**Requires:** temperature_number feature mode (use ``begin()``)
194+
195+
.. code-block:: arduino
196+
197+
bool setStep(double step);
198+
199+
* ``step`` - Temperature step value in Celsius
200+
201+
This function will return ``true`` if successful, ``false`` otherwise.
202+
203+
**Note:** The temperature_step feature requires the temperature_number feature to be enabled. This method will return ``false`` and log an error if called when using temperature_level mode.
204+
205+
getStep
206+
^^^^^^^
207+
208+
Gets the current temperature step value.
209+
210+
.. code-block:: arduino
211+
212+
double getStep();
213+
214+
This function will return the temperature step in Celsius with 1/100th degree precision.
215+
216+
Temperature Level Control (Optional)
217+
*************************************
218+
219+
setSelectedTemperatureLevel
220+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
221+
222+
Sets the selected temperature level.
223+
224+
**Requires:** temperature_level feature mode (use ``begin(supportedLevels, levelCount, selectedLevel)``)
225+
226+
.. code-block:: arduino
227+
228+
bool setSelectedTemperatureLevel(uint8_t level);
229+
230+
* ``level`` - Temperature level (0-255)
231+
232+
This function will return ``true`` if successful, ``false`` otherwise.
233+
234+
**Note:** Temperature level and temperature number features are mutually exclusive. This method will return ``false`` and log an error if called when using temperature_number mode.
235+
236+
getSelectedTemperatureLevel
237+
^^^^^^^^^^^^^^^^^^^^^^^^^^
238+
239+
Gets the current selected temperature level.
240+
241+
.. code-block:: arduino
242+
243+
uint8_t getSelectedTemperatureLevel();
244+
245+
This function will return the selected temperature level (0-255).
246+
247+
setSupportedTemperatureLevels
248+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
249+
250+
Sets the supported temperature levels array.
251+
252+
**Requires:** temperature_level feature mode (use ``begin(supportedLevels, levelCount, selectedLevel)``)
253+
254+
.. code-block:: arduino
255+
256+
bool setSupportedTemperatureLevels(uint8_t *levels, uint16_t count);
257+
258+
* ``levels`` - Pointer to array of temperature level values (array is copied internally)
259+
* ``count`` - Number of levels in the array (maximum: 16)
260+
261+
This function will return ``true`` if successful, ``false`` otherwise.
262+
263+
**Note:** The maximum number of supported levels is 16. The array is copied internally, so it does not need to remain valid after the function returns. This method will return ``false`` and log an error if called when using temperature_number mode or if count exceeds the maximum.
264+
265+
getSupportedTemperatureLevelsCount
266+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
267+
268+
Gets the count of supported temperature levels.
269+
270+
.. code-block:: arduino
271+
272+
uint16_t getSupportedTemperatureLevelsCount();
273+
274+
This function will return the number of supported temperature levels.
275+
276+
Example
277+
-------
278+
279+
Temperature Controlled Cabinet
280+
******************************
281+
282+
The example demonstrates the temperature_number mode with dynamic temperature updates. The temperature setpoint automatically cycles between the minimum and maximum limits every 1 second using the configured step value, allowing Matter controllers to observe real-time changes.
283+
284+
.. literalinclude:: ../../../libraries/Matter/examples/MatterTemperatureControlledCabinet/MatterTemperatureControlledCabinet.ino
285+
:language: arduino
286+
287+
Temperature Controlled Cabinet (Level Mode)
288+
********************************************
289+
290+
A separate example demonstrates the temperature_level mode with dynamic level updates. The temperature level automatically cycles through all supported levels every 1 second, allowing Matter controllers to observe real-time changes.
291+
292+
See ``MatterTemperatureControlledCabinetLevels`` example for the temperature level mode implementation.
293+

docs/en/matter/matter.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ The library provides specialized endpoint classes for different device types. Ea
130130

131131
**Control Endpoints:**
132132

133+
* ``MatterTemperatureControlledCabinet``: Temperature controlled cabinet (setpoint control with min/max limits)
134+
133135
* ``MatterFan``: Fan with speed and mode control
134136
* ``MatterThermostat``: Thermostat with temperature control and setpoints
135137
* ``MatterOnOffPlugin``: On/off plugin unit (power outlet/relay)

0 commit comments

Comments
 (0)