Skip to content

Commit ebd1509

Browse files
committed
Corrected checking of modes for WaterHeaterModes which must be included, and corrected the common modes.
1 parent 927a3ef commit ebd1509

File tree

1 file changed

+62
-13
lines changed

1 file changed

+62
-13
lines changed

src/python_testing/TC_EWATERHTRM_1_2.py

+62-13
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,30 @@ async def test_TC_EWATERHTRM_1_2(self):
6464
self.step(1)
6565

6666
self.step(2)
67-
supported_modes = await self.read_mod_attribute_expect_success(endpoint=endpoint, attribute=attributes.SupportedModes)
68-
asserts.assert_greater_equal(len(supported_modes), 2, "SupportedModes must have at least 2 entries!")
69-
asserts.assert_less_equal(len(supported_modes), 255, "SupportedModes must have at most 255 entries!")
67+
supported_modes = await self.read_mode_attribute_expect_success(endpoint=endpoint, attribute=attributes.SupportedModes)
68+
asserts.assert_greater_equal(len(supported_modes), 2,
69+
"SupportedModes must have at least 2 entries!")
70+
asserts.assert_less_equal(len(supported_modes), 255,
71+
"SupportedModes must have at most 255 entries!")
7072
modes = set([m.mode for m in supported_modes])
71-
asserts.assert_equal(len(modes), len(supported_modes), "SupportedModes must have unique mode values")
73+
asserts.assert_equal(len(modes), len(supported_modes),
74+
"SupportedModes must have unique mode values")
7275

7376
labels = set([m.label for m in supported_modes])
74-
asserts.assert_equal(len(labels), len(supported_modes), "SupportedModes must have unique mode label values")
77+
asserts.assert_equal(len(labels), len(supported_modes),
78+
"SupportedModes must have unique mode label values")
7579

7680
# common mode tags
77-
commonTags = {0x0: 'Off',
78-
0x1: 'Manual',
79-
0x2: 'Timed'}
81+
commonTags = {0x0: 'Auto',
82+
0x1: 'Quick',
83+
0x2: 'Quiet',
84+
0x3: 'LowNoise',
85+
0x4: 'LowEnergy',
86+
0x5: 'Vacation',
87+
0x6: 'Min',
88+
0x7: 'Max',
89+
0x8: 'Night',
90+
0x9: 'Day'}
8091

8192
# derived cluster defined tags
8293
# kUnknownEnumValue may not be defined
@@ -88,21 +99,59 @@ async def test_TC_EWATERHTRM_1_2(self):
8899

89100
logging.info("Derived tags: %s" % derivedTags)
90101

102+
# According to the Mode spec:
103+
# At least one entry in the SupportedModes attribute SHALL include the Manual mode tag in the ModeTags field list.
104+
# At least one entry in the SupportedModes attribute SHALL include the Off mode tag in the ModeTags field list.
105+
# An entry in the SupportedModes attribute that includes one of an Off, Manual, or Timed tag
106+
# SHALL NOT also include an additional instance of any one of these tag types.
107+
off_present = 0
108+
manual_present = 0
109+
timed_present = 0
110+
91111
for m in supported_modes:
112+
off_manual_timed_present_in_this_mode = 0
92113
for t in m.modeTags:
93114
is_mfg = (0x8000 <= t.value and t.value <= 0xBFFF)
94115
asserts.assert_true(t.value in commonTags.keys() or t.value in derivedTags or is_mfg,
95116
"Found a SupportedModes entry with invalid mode tag value!")
96117
if t.value == Clusters.WaterHeaterMode.Enums.ModeTag.kOff:
97-
off_present = True
98-
logging.info("Found normal mode tag %s with tag value %s", m.mode, t.value)
99-
100-
asserts.assert_true(off_present, "SupportedModes does not have an entry of Off(0x4000)")
118+
off_present += 1
119+
off_manual_timed_present_in_this_mode += 1
120+
logging.info(
121+
"Found Off mode tag %s with tag value %s", m.mode, t.value)
122+
123+
if t.value == Clusters.WaterHeaterMode.Enums.ModeTag.kManual:
124+
manual_present += 1
125+
off_manual_timed_present_in_this_mode += 1
126+
logging.info(
127+
"Found Manual mode tag %s with tag value %s", m.mode, t.value)
128+
129+
if t.value == Clusters.WaterHeaterMode.Enums.ModeTag.kTimed:
130+
timed_present += 1
131+
off_manual_timed_present_in_this_mode += 1
132+
logging.info(
133+
"Found Timed mode tag %s with tag value %s", m.mode, t.value)
134+
135+
asserts.assert_less_equal(off_manual_timed_present_in_this_mode, 1,
136+
f"The supported mode ({m.mode}) should only include one of OFF, MANUAL or TIMED, but includes more than one.")
137+
138+
asserts.assert_greater(off_present, 0,
139+
"SupportedModes does not have an entry of Off(0x4000)")
140+
asserts.assert_greater(manual_present, 0,
141+
"SupportedModes does not have an entry of Manual(0x4001)")
142+
143+
asserts.assert_less_equal(off_present, 1,
144+
"SupportedModes cannot have more than one instance of Off(0x4000)")
145+
asserts.assert_less_equal(manual_present, 1,
146+
"SupportedModes cannot have more than one instance of Manual(0x4001)")
147+
asserts.assert_less_equal(timed_present, 1,
148+
"SupportedModes cannot have more than one instance of Timed(0x4002)")
101149

102150
self.step(3)
103151
current_mode = await self.read_mode_attribute_expect_success(endpoint=endpoint, attribute=attributes.CurrentMode)
104152
logging.info("CurrentMode: %s" % current_mode)
105-
asserts.assert_true(current_mode in modes, "CurrentMode is not a supported mode!")
153+
asserts.assert_true(current_mode in modes,
154+
"CurrentMode is not a supported mode!")
106155

107156

108157
if __name__ == "__main__":

0 commit comments

Comments
 (0)