File tree Expand file tree Collapse file tree
src/app/clusters/valve-configuration-and-control-server Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,8 +153,25 @@ DataModel::ActionReturnStatus ValveConfigurationAndControlCluster::WriteImpl(con
153153
154154 if (request.path .mAttributeId == ValveConfigurationAndControl::Attributes::DefaultOpenDuration::Id)
155155 {
156- AttributePersistence persistence{ mContext ->attributeStorage };
157- return persistence.DecodeAndStoreNativeEndianValue (request.path , decoder, mDefaultOpenDuration );
156+ DataModel::Nullable<uint32_t > value;
157+ ReturnErrorOnFailure (decoder.Decode (value));
158+
159+ // DefaultOpenDuration has a constraint: min value = 1 (when not null)
160+ if (!value.IsNull () && value.Value () < 1 )
161+ {
162+ return CHIP_IM_GLOBAL_STATUS (ConstraintError);
163+ }
164+
165+ // Avoid rewriting storage if unchanged
166+ VerifyOrReturnValue (value != mDefaultOpenDuration , DataModel::ActionReturnStatus::FixedStatus::kWriteSuccessNoOp );
167+
168+ mDefaultOpenDuration = value;
169+
170+ // Persist using AttributePersistence nullable storage representation.
171+ NumericAttributeTraits<uint32_t >::StorageType storageValue;
172+ NullableToStorage (mDefaultOpenDuration , storageValue);
173+ return mContext ->attributeStorage .WriteValue (request.path ,
174+ { reinterpret_cast <const uint8_t *>(&storageValue), sizeof (storageValue) });
158175 }
159176
160177 if (request.path .mAttributeId == ValveConfigurationAndControl::Attributes::DefaultOpenLevel::Id)
You can’t perform that action at this time.
0 commit comments