@@ -468,6 +468,52 @@ void ThermostatAttrAccess::OnFabricRemoved(const FabricTable & fabricTable, Fabr
468
468
}
469
469
}
470
470
471
+ void MatterThermostatClusterServerAttributeChangedCallback (const ConcreteAttributePath & attributePath)
472
+ {
473
+ uint32_t flags;
474
+ if (FeatureMap::Get (attributePath.mEndpointId , &flags) != Status::Success)
475
+ {
476
+ ChipLogError (Zcl, " MatterThermostatClusterServerAttributeChangedCallback: could not get feature flags" );
477
+ return ;
478
+ }
479
+
480
+ auto featureMap = BitMask<Feature, uint32_t >(flags);
481
+ if (!featureMap.Has (Feature::kPresets ))
482
+ {
483
+ // This server does not support presets, so nothing to do
484
+ return ;
485
+ }
486
+
487
+ bool occupied = true ;
488
+ if (featureMap.Has (Feature::kOccupancy ))
489
+ {
490
+ BitMask<OccupancyBitmap, uint8_t > occupancy;
491
+ if (Occupancy::Get (attributePath.mEndpointId , &occupancy) == Status::Success)
492
+ {
493
+ occupied = occupancy.Has (OccupancyBitmap::kOccupied );
494
+ }
495
+ }
496
+
497
+ bool clearActivePreset = false ;
498
+ switch (attributePath.mAttributeId )
499
+ {
500
+ case OccupiedHeatingSetpoint::Id:
501
+ case OccupiedCoolingSetpoint::Id:
502
+ clearActivePreset = occupied;
503
+ break ;
504
+ case UnoccupiedHeatingSetpoint::Id:
505
+ case UnoccupiedCoolingSetpoint::Id:
506
+ clearActivePreset = !occupied;
507
+ break ;
508
+ }
509
+ if (!clearActivePreset)
510
+ {
511
+ return ;
512
+ }
513
+ ChipLogProgress (Zcl, " Setting active preset to null" );
514
+ gThermostatAttrAccess .SetActivePreset (attributePath.mEndpointId , std::nullopt);
515
+ }
516
+
471
517
} // namespace Thermostat
472
518
} // namespace Clusters
473
519
} // namespace app
@@ -762,6 +808,11 @@ MatterThermostatClusterServerPreAttributeChangedCallback(const app::ConcreteAttr
762
808
}
763
809
}
764
810
811
+ void MatterThermostatClusterServerAttributeChangedCallback (const ConcreteAttributePath & attributePath)
812
+ {
813
+ Thermostat::MatterThermostatClusterServerAttributeChangedCallback (attributePath);
814
+ }
815
+
765
816
bool emberAfThermostatClusterClearWeeklyScheduleCallback (app::CommandHandler * commandObj,
766
817
const app::ConcreteCommandPath & commandPath,
767
818
const Commands::ClearWeeklySchedule::DecodableType & commandData)
0 commit comments