Skip to content

Commit 102dfc6

Browse files
committed
feat(matter): adds specifc type name for thermostat auto mode enabled
1 parent f1eca7d commit 102dfc6

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

Diff for: libraries/Matter/examples/MatterThermostat/MatterThermostat.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void setup() {
7373

7474
// Simulated Thermostat in COOLING and HEATING mode with Auto Mode to keep the temperature between setpoints
7575
// Auto Mode can only be used when the control sequence of operation is Cooling & Heating
76-
SimulatedThermostat.begin(MatterThermostat::THERMOSTAT_SEQ_OP_COOLING_HEATING, true);
76+
SimulatedThermostat.begin(MatterThermostat::THERMOSTAT_SEQ_OP_COOLING_HEATING, MatterThermostat::THERMOSTAT_AUTO_MODE_ENABLED);
7777

7878
// Matter beginning - Last step, after all EndPoints are initialized
7979
Matter.begin();

Diff for: libraries/Matter/keywords.txt

+2
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,5 @@ THERMOSTAT_MODE_OFF LITERAL1
145145
THERMOSTAT_MODE_AUTO LITERAL1
146146
THERMOSTAT_MODE_COOL LITERAL1
147147
THERMOSTAT_MODE_HEAT LITERAL1
148+
THERMOSTAT_AUTO_MODE_DISABLED LITERAL1
149+
THERMOSTAT_AUTO_MODE_ENABLED LITERAL1

Diff for: libraries/Matter/src/MatterEndpoints/MatterThermostat.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ MatterThermostat::~MatterThermostat() {
165165
end();
166166
}
167167

168-
bool MatterThermostat::begin(ControlSequenceOfOperation_t _controlSequence, bool _hasAutoMode) {
168+
bool MatterThermostat::begin(ControlSequenceOfOperation_t _controlSequence, ThermostatAutoMode_t _autoMode) {
169169
ArduinoMatter::_init();
170170

171171
if (getEndPointId() != 0) {
@@ -174,7 +174,7 @@ bool MatterThermostat::begin(ControlSequenceOfOperation_t _controlSequence, bool
174174
}
175175

176176
// check if auto mode is allowed with the control sequence of operation - only allowed for Cooling & Heating
177-
if (_hasAutoMode && _controlSequence != THERMOSTAT_SEQ_OP_COOLING_HEATING && _controlSequence != THERMOSTAT_SEQ_OP_COOLING_HEATING_REHEAT) {
177+
if (_autoMode == THERMOSTAT_AUTO_MODE_ENABLED && _controlSequence != THERMOSTAT_SEQ_OP_COOLING_HEATING && _controlSequence != THERMOSTAT_SEQ_OP_COOLING_HEATING_REHEAT) {
178178
log_e("Thermostat in Auto Mode requires a Cooling & Heating Control Sequence of Operation.");
179179
return false;
180180
}
@@ -197,14 +197,14 @@ bool MatterThermostat::begin(ControlSequenceOfOperation_t _controlSequence, bool
197197
log_e("Failed to create Thermostat endpoint");
198198
return false;
199199
}
200-
if (_hasAutoMode) {
200+
if (_autoMode == THERMOSTAT_AUTO_MODE_ENABLED) {
201201
cluster_t *cluster = cluster::get(endpoint, Thermostat::Id);
202202
thermostat_config.thermostat.auto_mode.min_setpoint_dead_band = kDefaultDeadBand; // fixed by default to 2.5C
203203
cluster::thermostat::feature::auto_mode::add(cluster, &thermostat_config.thermostat.auto_mode);
204204
}
205205

206206
controlSequence = _controlSequence;
207-
hasAutoMode = _hasAutoMode;
207+
autoMode = _autoMode;
208208
coolingSetpointTemperature = _coolingSetpointTemperature;
209209
heatingSetpointTemperature = _heatingSetpointTemperature;
210210
localTemperature = _localTemperature;
@@ -226,7 +226,7 @@ bool MatterThermostat::setMode(ThermostatMode_t _mode) {
226226
return false;
227227
}
228228

229-
if (!hasAutoMode && _mode == THERMOSTAT_MODE_AUTO) {
229+
if (autoMode == THERMOSTAT_AUTO_MODE_DISABLED && _mode == THERMOSTAT_MODE_AUTO) {
230230
log_e("Thermostat can't set Auto Mode.");
231231
return false;
232232
}

Diff for: libraries/Matter/src/MatterEndpoints/MatterThermostat.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,17 @@ class MatterThermostat : public MatterEndPoint {
4040
THERMOSTAT_MODE_COOL = (uint8_t) Thermostat::SystemModeEnum::kCool,
4141
THERMOSTAT_MODE_HEAT = (uint8_t) Thermostat::SystemModeEnum::kHeat,
4242
};
43+
44+
enum ThermostatAutoMode_t {
45+
THERMOSTAT_AUTO_MODE_DISABLED = (uint8_t) Thermostat::SystemModeEnum::kOff,
46+
THERMOSTAT_AUTO_MODE_ENABLED = (uint8_t) Thermostat::SystemModeEnum::kAuto,
47+
};
4348
// clang-format on
4449

4550
MatterThermostat();
4651
~MatterThermostat();
4752
// begin Matter Thermostat endpoint with initial Operation Mode
48-
bool begin(ControlSequenceOfOperation_t controlSequence = THERMOSTAT_SEQ_OP_COOLING, bool hasAutoMode = false);
53+
bool begin(ControlSequenceOfOperation_t controlSequence = THERMOSTAT_SEQ_OP_COOLING, ThermostatAutoMode_t autoMode = THERMOSTAT_AUTO_MODE_DISABLED);
4954
// this will stop processing Thermostat Matter events
5055
void end();
5156

@@ -218,7 +223,7 @@ class MatterThermostat : public MatterEndPoint {
218223

219224
ThermostatMode_t currentMode = THERMOSTAT_MODE_OFF;
220225
ControlSequenceOfOperation_t controlSequence = THERMOSTAT_SEQ_OP_COOLING;
221-
bool hasAutoMode = false;
226+
ThermostatAutoMode_t autoMode = THERMOSTAT_AUTO_MODE_DISABLED;
222227

223228
EndPointModeCB _onChangeModeCB = NULL;
224229
EndPointTemperatureCB _onChangeTemperatureCB = NULL;

0 commit comments

Comments
 (0)