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

Add support for Presets attributes and commands to the Thermostat cluster #34532

Merged
merged 16 commits into from
Jul 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Restyled by whitespace
restyled-commits authored and nivi-apple committed Jul 26, 2024
commit 5d2c7402dd9ea58190caf79bb20a30064bfb0fdc
6 changes: 3 additions & 3 deletions examples/thermostat/linux/thermostat-delegate-impl.cpp
Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ void ThermostatDelegate::InitializePresetTypes()
for (PresetScenarioEnum presetScenario : presetScenarioEnumArray)
{
mPresetTypes[index].presetScenario = presetScenario;
mPresetTypes[index].numberOfPresets = kMaxNumberOfPresetTypesOfEachType;
mPresetTypes[index].numberOfPresets = kMaxNumberOfPresetTypesOfEachType;
mPresetTypes[index].presetTypeFeatures =
(presetScenario == PresetScenarioEnum::kOccupied || presetScenario == PresetScenarioEnum::kUnoccupied) ?
PresetTypeFeaturesBitmap::kAutomatic : PresetTypeFeaturesBitmap::kSupportsNames;
@@ -97,7 +97,7 @@ void ThermostatDelegate::InitializePresets()
int16_t coolingSetpointValue = 2500 + index * 100;
mPresets[index].SetCoolingSetpoint(MakeOptional(coolingSetpointValue));

int16_t heatingSetpointValue = 2100 - index * 100;
int16_t heatingSetpointValue = 2100 - index * 100;
mPresets[index].SetHeatingSetpoint(MakeOptional(heatingSetpointValue));
mPresets[index].SetBuiltIn(DataModel::MakeNullable(true));
index++;
@@ -228,7 +228,7 @@ CHIP_ERROR ThermostatDelegate::ApplyPendingPresets()
// If pending preset was not found in the Presets list, append to the Presets list.
if (!found)
{

mPresets[mNextFreeIndexInPresetsList] = pendingPreset;

const uint8_t handle[] = { static_cast<uint8_t>(pendingPreset.GetPresetScenario()) };
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ CHIP_ERROR PresetStructWithOwnedMembers::SetPresetHandle(const Nullable<ByteSpan
{
presetHandle.SetNull();
}

return CHIP_NO_ERROR;
}

@@ -98,7 +98,7 @@ CHIP_ERROR PresetStructWithOwnedMembers::SetName(const Optional<DataModel::Nulla
else
{
name.ClearValue();
}
}
return CHIP_NO_ERROR;
}

6 changes: 3 additions & 3 deletions src/app/clusters/thermostat-server/thermostat-server.cpp
Original file line number Diff line number Diff line change
@@ -1463,7 +1463,7 @@ bool emberAfThermostatClusterCommitPresetsSchedulesRequestCallback(
{
foundMatchingPresetInPresets = GetMatchingPresetInPresets(delegate, pendingPreset, matchingPreset);

// #7. If the presetHandle for the pending preset is not null and a matching preset is not found in the
// #7. If the presetHandle for the pending preset is not null and a matching preset is not found in the
// presets attribute list, return NOT_FOUND.
if (!foundMatchingPresetInPresets)
{
@@ -1500,11 +1500,11 @@ bool emberAfThermostatClusterCommitPresetsSchedulesRequestCallback(
return SendResponseAndCleanUp(delegate, endpoint, commandObj, commandPath, imcode::ConstraintError);
}

// #12. If the preset type for the preset scenario does not supports names and a name is specified, return CONSTRAINT_ERROR.
// #12. If the preset type for the preset scenario does not supports names and a name is specified, return CONSTRAINT_ERROR.
if (!PresetTypeSupportsNames(delegate, presetScenario) && pendingPreset.GetName().HasValue())
{
return SendResponseAndCleanUp(delegate, endpoint, commandObj, commandPath, imcode::ConstraintError);
}
}

// Enforce the Setpoint Limits for both the cooling and heating
Optional<int16_t> coolingSetpointValue = preset.GetCoolingSetpoint();
1 change: 0 additions & 1 deletion src/app/clusters/thermostat-server/thermostat-server.h
Original file line number Diff line number Diff line change
@@ -102,4 +102,3 @@ void SetDefaultDelegate(EndpointId endpoint, Delegate * delegate);
} // namespace Clusters
} // namespace app
} // namespace chip