|
| 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) |
0 commit comments