diff --git a/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp b/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp index 4a736cecd01ac6..006311d6f0c9b1 100644 --- a/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp +++ b/src/app/clusters/microwave-oven-control-server/microwave-oven-control-server.cpp @@ -296,7 +296,7 @@ void Instance::HandleSetCookingParameters(HandlerContext & ctx, const Commands:: ChipLogError(Zcl, "Microwave Oven Control: Failed to set PowerSetting, PowerSetting value is out of range")); VerifyOrExit( - reqPowerSettingNum % powerStepNum == 0, status = Status::InvalidCommand; ChipLogError( + (reqPowerSettingNum - minPowerNum) % powerStepNum == 0, status = Status::ConstraintError; ChipLogError( Zcl, "Microwave Oven Control: Failed to set PowerSetting, PowerSetting value must be multiple of PowerStep number")); diff --git a/src/python_testing/TC_MWOCTRL_2_2.py b/src/python_testing/TC_MWOCTRL_2_2.py index a728d036cc7a8e..9c659cf971b708 100644 --- a/src/python_testing/TC_MWOCTRL_2_2.py +++ b/src/python_testing/TC_MWOCTRL_2_2.py @@ -45,7 +45,7 @@ async def set_power_setting_expect_failure(self, endpoint, value): asserts.assert_fail("Expected an exception but received none.") except InteractionModelError as e: asserts.assert_equal(e.status, Status.ConstraintError, - "Expected ConstraintError but received a different response: %x", e.status) + "Expected ConstraintError but received a different response") async def read_and_check_power_setting_value(self, endpoint, value): powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=Clusters.MicrowaveOvenControl.Attributes.PowerSetting) @@ -103,31 +103,36 @@ async def test_TC_MWOCTRL_2_2(self): self.step(2) minPowerValue = 10 + feature_map = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.FeatureMap) + is_pwrnum_feature_supported = feature_map & features.kPowerAsNumber + is_watts_feature_supported = feature_map & features.kPowerInWatts + is_pwrlmits_feature_supported = feature_map & features.kPowerNumberLimits + self.step(3) - if self.pics_guard(self.check_pics("MWOCTRL.S.F02")): + if is_pwrlmits_feature_supported: minPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MinPower) - logging.info("MinPower is %s" % minPowerValue) asserts.assert_true(minPowerValue >= 1, "MinPower is less than 1") + logging.info("MinPower is %s" % minPowerValue) self.step(4) maxPowerValue = 100 self.step(5) - if self.pics_guard(self.check_pics("MWOCTRL.S.F02")): + if is_pwrlmits_feature_supported: maxPowerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.MaxPower) - logging.info("MaxPower is %s" % maxPowerValue) asserts.assert_true(maxPowerValue >= minPowerValue, "MaxPower is less than MinPower") asserts.assert_true(maxPowerValue <= 100, "MaxPower is greater than 100") + logging.info("MaxPower is %s" % maxPowerValue) self.step(6) powerStepValue = 10 self.step(7) - if self.pics_guard(self.check_pics("MWOCTRL.S.F02")): + if is_pwrlmits_feature_supported: powerStepValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerStep) - logging.info("PowerStep is %s" % powerStepValue) asserts.assert_true(powerStepValue >= 1, "PowerStep is less than 1") asserts.assert_true(powerStepValue <= maxPowerValue, "PowerStep is greater than MaxPower") + logging.info("PowerStep is %s" % powerStepValue) self.step(8) powerValue = await self.read_mwoctrl_attribute_expect_success(endpoint=endpoint, attribute=attributes.PowerSetting)