-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[Fix] Apply preset setpoints when changing active preset #43587
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
ff9378b
ca6eb82
4a13b08
c10c4cb
16082d7
1d2a162
eddb5a0
cc54de0
44dab5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -302,10 +302,38 @@ Status ThermostatAttrAccess::SetActivePreset(EndpointId endpoint, DataModel::Nul | |
| return Status::InvalidInState; | ||
| } | ||
|
|
||
| // If the preset handle passed in the command is not present in the Presets attribute, return INVALID_COMMAND. | ||
| if (!presetHandle.IsNull() && !IsPresetHandlePresentInPresets(delegate, presetHandle.Value())) | ||
| if (!presetHandle.IsNull()) | ||
| { | ||
| return Status::InvalidCommand; | ||
| PresetStructWithOwnedMembers matchingPreset; | ||
| // Look up the preset once and reuse it to apply any setpoints it carries. | ||
| if (!GetMatchingPresetInPresets(delegate, presetHandle, matchingPreset)) | ||
| { | ||
| return Status::InvalidCommand; | ||
| } | ||
lboue marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Optional<int16_t> coolingSetpointValue = matchingPreset.GetCoolingSetpoint(); | ||
| if (coolingSetpointValue.HasValue()) | ||
| { | ||
| Status status = | ||
| OccupiedCoolingSetpoint::Set(endpoint, EnforceCoolingSetpointLimits(coolingSetpointValue.Value(), endpoint)); | ||
| if (status != Status::Success) | ||
lboue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| ChipLogError(Zcl, "Failed to set OccupiedCoolingSetpoint with status %u", to_underlying(status)); | ||
| return status; | ||
| } | ||
|
Comment on lines
+331
to
+337
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I addressed the re-entrancy concern directly in I also kept the existing error propagation behavior ( |
||
| } | ||
|
|
||
| Optional<int16_t> heatingSetpointValue = matchingPreset.GetHeatingSetpoint(); | ||
| if (heatingSetpointValue.HasValue()) | ||
| { | ||
| Status status = | ||
| OccupiedHeatingSetpoint::Set(endpoint, EnforceHeatingSetpointLimits(heatingSetpointValue.Value(), endpoint)); | ||
| if (status != Status::Success) | ||
lboue marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| ChipLogError(Zcl, "Failed to set OccupiedHeatingSetpoint with status %u", to_underlying(status)); | ||
| return status; | ||
| } | ||
lboue marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
Comment on lines
+328
to
+350
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This re-entrancy path is now guarded in |
||
| } | ||
|
|
||
| CHIP_ERROR err = delegate->SetActivePresetHandle(presetHandle); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.