@@ -64,19 +64,30 @@ async def test_TC_EWATERHTRM_1_2(self):
64
64
self .step (1 )
65
65
66
66
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!" )
70
72
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" )
72
75
73
76
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" )
75
79
76
80
# 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' }
80
91
81
92
# derived cluster defined tags
82
93
# kUnknownEnumValue may not be defined
@@ -88,21 +99,59 @@ async def test_TC_EWATERHTRM_1_2(self):
88
99
89
100
logging .info ("Derived tags: %s" % derivedTags )
90
101
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
+
91
111
for m in supported_modes :
112
+ off_manual_timed_present_in_this_mode = 0
92
113
for t in m .modeTags :
93
114
is_mfg = (0x8000 <= t .value and t .value <= 0xBFFF )
94
115
asserts .assert_true (t .value in commonTags .keys () or t .value in derivedTags or is_mfg ,
95
116
"Found a SupportedModes entry with invalid mode tag value!" )
96
117
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)" )
101
149
102
150
self .step (3 )
103
151
current_mode = await self .read_mode_attribute_expect_success (endpoint = endpoint , attribute = attributes .CurrentMode )
104
152
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!" )
106
155
107
156
108
157
if __name__ == "__main__" :
0 commit comments