Skip to content

Commit 40e4c8c

Browse files
committed
Implement TC_EWATERHTR_2_1.py
1 parent 9357945 commit 40e4c8c

File tree

2 files changed

+175
-0
lines changed

2 files changed

+175
-0
lines changed

src/python_testing/EWATERHTRBase.py

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#
2+
# Copyright (c) 2023 Project CHIP Authors
3+
# All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
import logging
19+
import typing
20+
21+
import chip.clusters as Clusters
22+
from chip.interaction_model import InteractionModelError, Status
23+
from mobly import asserts
24+
25+
logger = logging.getLogger(__name__)
26+
27+
28+
class EWATERHTRBase:
29+
30+
async def read_whm_attribute_expect_success(self, endpoint: int = None, attribute: str = ""):
31+
cluster = Clusters.Objects.WaterHeaterManagement
32+
full_attr = getattr(cluster.Attributes, attribute)
33+
return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=full_attr)
34+
35+
async def check_whm_attribute(self, attribute, expected_value, endpoint: int = None):
36+
value = await self.read_whm_attribute_expect_success(endpoint=endpoint, attribute=attribute)
37+
asserts.assert_equal(value, expected_value,
38+
f"Unexpected '{attribute}' value - expected {expected_value}, was {value}")
39+
40+
async def send_boost_command(self, duration: int, one_shot: typing.Optional[bool], emergency_boost: typing.Optional[bool],
41+
temporary_setpoint: typing.Optional[int], target_percentage: typing.Optional[int] , target_reheat: typing.Optional[int],
42+
endpoint: int = None, timedRequestTimeoutMs: int = 3000,
43+
expected_status: Status = Status.Success):
44+
try:
45+
await self.send_single_cmd(cmd=Clusters.WaterHeaterManagement.Commands.Boost(
46+
duration=duration,
47+
oneShot=one_shot,
48+
emergencyBoost=emergency_boost,
49+
temporarySetpoint=temporary_setpoint,
50+
targetPercentage=target_percentage,
51+
targetReheat=target_reheat,
52+
endpoint=endpoint,
53+
timedRequestTimeoutMs=timedRequestTimeoutMs))
54+
55+
asserts.assert_equal(expected_status, Status.Success)
56+
57+
except InteractionModelError as e:
58+
asserts.assert_equal(e.status, expected_status, "Unexpected error returned")
59+
60+
async def send_cancel_boost_command(self, endpoint: int = None, timedRequestTimeoutMs: int = 3000,
61+
expected_status: Status = Status.Success):
62+
try:
63+
await self.send_single_cmd(cmd=Clusters.WaterHeaterManagement.Commands.CancelBoost(),
64+
endpoint=endpoint,
65+
timedRequestTimeoutMs=timedRequestTimeoutMs)
66+
67+
asserts.assert_equal(expected_status, Status.Success)
68+
69+
except InteractionModelError as e:
70+
asserts.assert_equal(e.status, expected_status, "Unexpected error returned")
71+
72+
async def send_test_event_trigger_basic_installation_test_event(self):
73+
await self.send_test_event_triggers(eventTrigger=0x0098000000000000)
74+
75+
async def send_test_event_trigger_basic_installation_test_eventClear(self):
76+
await self.send_test_event_triggers(eventTrigger=0x0098000000000001)
77+
78+
async def send_test_event_trigger_water_temperature20C_test_event(self):
79+
await self.send_test_event_triggers(eventTrigger=0x0098000000000002)
80+
81+
async def send_test_event_trigger_water_temperature61C_test_event(self):
82+
await self.send_test_event_triggers(eventTrigger=0x0098000000000003)
83+
84+
async def send_test_event_trigger_water_temperature66C_test_event(self):
85+
await self.send_test_event_triggers(eventTrigger=0x0098000000000004)
86+
87+
async def send_test_event_trigger_manual_mode_test_event(self):
88+
await self.send_test_event_triggers(eventTrigger=0x0098000000000005)
89+
90+
async def send_test_event_trigger_off_mode_test_event(self):
91+
await self.send_test_event_triggers(eventTrigger=0x0098000000000006)
92+
93+
async def send_test_event_trigger_draw_off_hot_water_test_event(self):
94+
await self.send_test_event_triggers(eventTrigger=0x0098000000000007)
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#
2+
# Copyright (c) 2024 Project CHIP Authors
3+
# All rights reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
import logging
19+
20+
import chip.clusters as Clusters
21+
from chip.clusters.Types import NullValue
22+
from chip.interaction_model import InteractionModelError, Status
23+
from matter_testing_support import EventChangeCallback, MatterBaseTest, TestStep, async_test_body, default_matter_test_main
24+
from mobly import asserts
25+
from EWATERHTRBase import EWATERHTRBase
26+
27+
logger = logging.getLogger(__name__)
28+
29+
30+
class TC_EWATERHTR_2_1(MatterBaseTest, EWATERHTRBase):
31+
32+
def desc_TC_EWATERHTR_2_1(self) -> str:
33+
"""Returns a description of this test"""
34+
return "[TC-EWATERHTR-2.1] Attributes with attributes with DUT as Server\n" \
35+
"This test case verifies the non-global attributes of the Water Heater Management cluster server."
36+
37+
def pics_TC_EWATERHTR_2_1(self):
38+
""" This function returns a list of PICS for this test case that must be True for the test to be run"""
39+
return ["EWATERHTR.S", "EWATERHTR.S.F00"]
40+
41+
def steps_TC_EWATERHTR_2_1(self) -> list[TestStep]:
42+
steps = [
43+
TestStep("1", "Commissioning, already done", is_commissioning=True),
44+
TestStep("2a", "TH reads HeaterTypes attribute. DUT as Server replies with a WaterHeaterTypeBitmap (enum8) value to match the DUT type."),
45+
TestStep("2b", "TH reads HeatDemand attribute. DUT as Server replies with a WaterHeaterDemandBitmap (enum8)."),
46+
TestStep("2c", "TH reads TankVolume attribute. DUT as Server replies with a uint16 value."),
47+
TestStep("2d", "TH reads EstimatedHeatRequired attribute. DUT as Server replies with an energy-mWh value."),
48+
TestStep("2e", "TH reads TankPercentage attribute. DUT as Server replies with a percent value."),
49+
TestStep("2f", "TH reads BoostState attribute. DUT as Server replies with a BoostStateEnum (enum8) value."),
50+
]
51+
52+
return steps
53+
54+
@async_test_body
55+
async def test_TC_EWATERHTR_2_1(self):
56+
57+
self.step("1")
58+
# Commission DUT - already done
59+
60+
# Note the values used here are configured in WhmManufacturer::Init()
61+
self.step("2a")
62+
await self.check_whm_attribute("HeaterTypes", Clusters.WaterHeaterManagement.Bitmaps.WaterHeaterTypeBitmap.kImmersionElement1)
63+
64+
self.step("2b")
65+
await self.check_whm_attribute("HeatDemand", Clusters.WaterHeaterManagement.Bitmaps.WaterHeaterDemandBitmap.kImmersionElement1)
66+
67+
self.step("2c")
68+
await self.check_whm_attribute("TankVolume", 20)
69+
70+
self.step("2d")
71+
await self.check_whm_attribute("EstimatedHeatRequired", 10000)
72+
73+
self.step("2e")
74+
await self.check_whm_attribute("TankPercentage", 35)
75+
76+
self.step("2f")
77+
await self.check_whm_attribute("BoostState", Clusters.WaterHeaterManagement.Enums.BoostStateEnum.kInactive)
78+
79+
80+
if __name__ == "__main__":
81+
default_matter_test_main()

0 commit comments

Comments
 (0)