-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add water heater management test scripts
- Loading branch information
1 parent
05e4c10
commit f9dfb28
Showing
4 changed files
with
700 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# | ||
# Copyright (c) 2023 Project CHIP Authors | ||
# All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
import logging | ||
import typing | ||
|
||
import chip.clusters as Clusters | ||
from chip.interaction_model import InteractionModelError, Status | ||
from mobly import asserts | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class EWATERHTRBase: | ||
|
||
async def read_whm_attribute_expect_success(self, endpoint: int = None, attribute: str = ""): | ||
cluster = Clusters.Objects.WaterHeaterManagement | ||
full_attr = getattr(cluster.Attributes, attribute) | ||
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=full_attr) | ||
|
||
async def check_whm_attribute(self, attribute, expected_value, endpoint: int = None): | ||
value = await self.read_whm_attribute_expect_success(endpoint=endpoint, attribute=attribute) | ||
asserts.assert_equal(value, expected_value, | ||
f"Unexpected '{attribute}' value - expected {expected_value}, was {value}") | ||
|
||
async def send_boost_command(self, duration: int, one_shot: typing.Optional[bool] = None, emergency_boost: typing.Optional[bool] = None, | ||
temporary_setpoint: typing.Optional[int] = None, target_percentage: typing.Optional[int] = None, target_reheat: typing.Optional[int] = None, | ||
endpoint: int = None, timedRequestTimeoutMs: int = 3000, | ||
expected_status: Status = Status.Success): | ||
try: | ||
await self.send_single_cmd(cmd=Clusters.WaterHeaterManagement.Commands.Boost( | ||
duration=duration, | ||
oneShot=one_shot, | ||
emergencyBoost=emergency_boost, | ||
temporarySetpoint=temporary_setpoint, | ||
targetPercentage=target_percentage, | ||
targetReheat=target_reheat), | ||
endpoint=endpoint, | ||
timedRequestTimeoutMs=timedRequestTimeoutMs) | ||
|
||
asserts.assert_equal(expected_status, Status.Success) | ||
|
||
except InteractionModelError as e: | ||
asserts.assert_equal(e.status, expected_status, "Unexpected error returned") | ||
|
||
async def send_cancel_boost_command(self, endpoint: int = None, timedRequestTimeoutMs: int = 3000, | ||
expected_status: Status = Status.Success): | ||
try: | ||
await self.send_single_cmd(cmd=Clusters.WaterHeaterManagement.Commands.CancelBoost(), | ||
endpoint=endpoint, | ||
timedRequestTimeoutMs=timedRequestTimeoutMs) | ||
|
||
asserts.assert_equal(expected_status, Status.Success) | ||
|
||
except InteractionModelError as e: | ||
asserts.assert_equal(e.status, expected_status, "Unexpected error returned") | ||
|
||
async def send_test_event_trigger_basic_installation_test_event(self): | ||
await self.send_test_event_triggers(eventTrigger=0x0094000000000000) | ||
|
||
async def send_test_event_trigger_basic_installation_test_event_clear(self): | ||
await self.send_test_event_triggers(eventTrigger=0x0094000000000001) | ||
|
||
async def send_test_event_trigger_water_temperature20C_test_event(self): | ||
await self.send_test_event_triggers(eventTrigger=0x0094000000000002) | ||
|
||
async def send_test_event_trigger_water_temperature61C_test_event(self): | ||
await self.send_test_event_triggers(eventTrigger=0x0094000000000003) | ||
|
||
async def send_test_event_trigger_water_temperature66C_test_event(self): | ||
await self.send_test_event_triggers(eventTrigger=0x0094000000000004) | ||
|
||
async def send_test_event_trigger_manual_mode_test_event(self): | ||
await self.send_test_event_triggers(eventTrigger=0x0094000000000005) | ||
|
||
async def send_test_event_trigger_off_mode_test_event(self): | ||
await self.send_test_event_triggers(eventTrigger=0x0094000000000006) | ||
|
||
async def send_test_event_trigger_draw_off_hot_water_test_event(self): | ||
await self.send_test_event_triggers(eventTrigger=0x0094000000000007) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# | ||
# Copyright (c) 2024 Project CHIP Authors | ||
# All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
import logging | ||
|
||
import chip.clusters as Clusters | ||
from EWATERHTRBase import EWATERHTRBase | ||
from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class TC_EWATERHTR_2_1(MatterBaseTest, EWATERHTRBase): | ||
|
||
def desc_TC_EWATERHTR_2_1(self) -> str: | ||
"""Returns a description of this test""" | ||
return "[TC-EWATERHTR-2.1] Attributes with attributes with DUT as Server\n" \ | ||
"This test case verifies the non-global attributes of the Water Heater Management cluster server." | ||
|
||
def pics_TC_EWATERHTR_2_1(self): | ||
""" This function returns a list of PICS for this test case that must be True for the test to be run""" | ||
return ["EWATERHTR.S", "EWATERHTR.S.F00", "EWATERHTR.S.F01"] | ||
|
||
def steps_TC_EWATERHTR_2_1(self) -> list[TestStep]: | ||
steps = [ | ||
TestStep("1", "Commissioning, already done", is_commissioning=True), | ||
TestStep("2a", "TH reads HeaterTypes attribute. DUT as Server replies with a WaterHeaterTypeBitmap (enum8) value to match the DUT type."), | ||
TestStep("2b", "TH reads HeatDemand attribute. DUT as Server replies with a WaterHeaterDemandBitmap (enum8)."), | ||
TestStep("2c", "TH reads TankVolume attribute. DUT as Server replies with a uint16 value."), | ||
TestStep("2d", "TH reads EstimatedHeatRequired attribute. DUT as Server replies with an energy-mWh value."), | ||
TestStep("2e", "TH reads TankPercentage attribute. DUT as Server replies with a percent value."), | ||
TestStep("2f", "TH reads BoostState attribute. DUT as Server replies with a BoostStateEnum (enum8) value."), | ||
] | ||
|
||
return steps | ||
|
||
@async_test_body | ||
async def test_TC_EWATERHTR_2_1(self): | ||
|
||
self.step("1") | ||
# Commission DUT - already done | ||
|
||
# Note the values used here are configured in WhmManufacturer::Init() | ||
self.step("2a") | ||
await self.check_whm_attribute("HeaterTypes", 0) | ||
|
||
self.step("2b") | ||
await self.check_whm_attribute("HeatDemand", 0) | ||
|
||
self.step("2c") | ||
await self.check_whm_attribute("TankVolume", 0) | ||
|
||
self.step("2d") | ||
await self.check_whm_attribute("EstimatedHeatRequired", 0) | ||
|
||
self.step("2e") | ||
await self.check_whm_attribute("TankPercentage", 0) | ||
|
||
self.step("2f") | ||
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kInactive) | ||
|
||
|
||
if __name__ == "__main__": | ||
default_matter_test_main() |
Oops, something went wrong.