@@ -101,6 +101,16 @@ def get_available_scenario(self, presetTypes: list, presetScenarioCounts: map):
101
101
return availableScenarios [0 ]
102
102
return None
103
103
104
+ def make_preset (self , presetScenario , coolSetpoint , heatSetpoint , presetHandle = NullValue , name = None , builtIn = False ):
105
+ preset = cluster .Structs .PresetStruct (presetHandle = presetHandle , presetScenario = presetScenario , builtIn = builtIn )
106
+ if self .check_pics ("TSTAT.S.F00" ):
107
+ preset .heatingSetpoint = heatSetpoint
108
+ if self .check_pics ("TSTAT.S.F01" ):
109
+ preset .coolingSetpoint = coolSetpoint
110
+ if name is not None :
111
+ preset .name = name
112
+ return preset
113
+
104
114
async def write_presets (self ,
105
115
endpoint ,
106
116
presets ,
@@ -255,13 +265,29 @@ async def test_TC_TSTAT_4_2(self):
255
265
presetTypes = []
256
266
presetScenarioCounts = {}
257
267
numberOfPresetsSupported = 0
258
- minHeatSetpointLimit = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .MinHeatSetpointLimit )
259
- maxHeatSetpointLimit = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .MaxHeatSetpointLimit )
260
- minCoolSetpointLimit = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .MinCoolSetpointLimit )
261
- maxCoolSetpointLimit = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .MaxCoolSetpointLimit )
268
+ minHeatSetpointLimit = 700
269
+ maxHeatSetpointLimit = 3000
270
+ minCoolSetpointLimit = 1600
271
+ maxCoolSetpointLimit = 3200
272
+
273
+ supportsHeat = self .check_pics ("TSTAT.S.F00" )
274
+ supportsCool = self .check_pics ("TSTAT.S.F01" )
275
+ supportsOccupancy = self .check_pics ("TSTAT.S.F02" )
276
+
277
+ occupied = True
262
278
263
- asserts .assert_true (minHeatSetpointLimit < maxHeatSetpointLimit , "Heat setpoint range invalid" )
264
- asserts .assert_true (minCoolSetpointLimit < maxCoolSetpointLimit , "Cool setpoint range invalid" )
279
+ if supportsHeat :
280
+ minHeatSetpointLimit = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .MinHeatSetpointLimit )
281
+ maxHeatSetpointLimit = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .MaxHeatSetpointLimit )
282
+ asserts .assert_true (minHeatSetpointLimit < maxHeatSetpointLimit , "Heat setpoint range invalid" )
283
+
284
+ if supportsCool :
285
+ minCoolSetpointLimit = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .MinCoolSetpointLimit )
286
+ maxCoolSetpointLimit = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .MaxCoolSetpointLimit )
287
+ asserts .assert_true (minCoolSetpointLimit < maxCoolSetpointLimit , "Cool setpoint range invalid" )
288
+
289
+ if supportsOccupancy :
290
+ occupied = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .Occupancy ) & 1
265
291
266
292
heatSetpoint = minHeatSetpointLimit + ((maxHeatSetpointLimit - minHeatSetpointLimit ) / 2 )
267
293
coolSetpoint = minCoolSetpointLimit + ((maxCoolSetpointLimit - minCoolSetpointLimit ) / 2 )
@@ -296,8 +322,7 @@ async def test_TC_TSTAT_4_2(self):
296
322
for preset in test_presets :
297
323
preset .builtIn = NullValue
298
324
299
- test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = availableScenario ,
300
- coolingSetpoint = coolSetpoint , heatingSetpoint = heatSetpoint , builtIn = False ))
325
+ test_presets .append (self .make_preset (availableScenario , coolSetpoint , heatSetpoint ))
301
326
302
327
await self .send_atomic_request_begin_command ()
303
328
@@ -334,8 +359,7 @@ async def test_TC_TSTAT_4_2(self):
334
359
if len (builtInPresets ) > 0 :
335
360
builtInPresets [0 ].builtIn = NullValue
336
361
337
- test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = availableScenario ,
338
- coolingSetpoint = coolSetpoint , heatingSetpoint = heatSetpoint , builtIn = False ))
362
+ test_presets .append (self .make_preset (availableScenario , coolSetpoint , heatSetpoint ))
339
363
340
364
# Send the AtomicRequest begin command
341
365
await self .send_atomic_request_begin_command ()
@@ -415,7 +439,16 @@ async def test_TC_TSTAT_4_2(self):
415
439
"Couldn't run test step 6 since there were no non-built-in presets to activate and delete" )
416
440
417
441
# Write the occupied cooling setpoint to a different value
418
- await self .write_single_attribute (attribute_value = cluster .Attributes .OccupiedCoolingSetpoint (2300 ), endpoint_id = endpoint )
442
+ if occupied :
443
+ if supportsHeat :
444
+ await self .write_single_attribute (attribute_value = cluster .Attributes .OccupiedHeatingSetpoint (heatSetpoint + 1 ), endpoint_id = endpoint )
445
+ elif supportsCool :
446
+ await self .write_single_attribute (attribute_value = cluster .Attributes .OccupiedCoolingSetpoint (coolSetpoint + 1 ), endpoint_id = endpoint )
447
+ else :
448
+ if supportsHeat :
449
+ await self .write_single_attribute (attribute_value = cluster .Attributes .UnoccupiedHeatingSetpoint (heatSetpoint + 1 ), endpoint_id = endpoint )
450
+ elif supportsCool :
451
+ await self .write_single_attribute (attribute_value = cluster .Attributes .UnoccupiedCoolingSetpoint (coolSetpoint + 1 ), endpoint_id = endpoint )
419
452
420
453
activePresetHandle = await self .read_single_attribute_check_success (endpoint = endpoint , cluster = cluster , attribute = cluster .Attributes .ActivePresetHandle )
421
454
logger .info (f"Rx'd ActivePresetHandle: { activePresetHandle } " )
@@ -456,8 +489,7 @@ async def test_TC_TSTAT_4_2(self):
456
489
await self .send_atomic_request_begin_command ()
457
490
458
491
# Write to the presets attribute after adding a preset with builtIn set to True
459
- test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = availableScenario ,
460
- coolingSetpoint = coolSetpoint , heatingSetpoint = heatSetpoint , builtIn = True ))
492
+ test_presets .append (self .make_preset (availableScenario , coolSetpoint , heatSetpoint , builtIn = True ))
461
493
462
494
status = await self .write_presets (endpoint = endpoint , presets = test_presets , expected_status = Status .ConstraintError )
463
495
@@ -475,8 +507,8 @@ async def test_TC_TSTAT_4_2(self):
475
507
476
508
# Write to the presets attribute after adding a preset with a preset handle that doesn't exist in Presets attribute
477
509
test_presets = copy .deepcopy (current_presets )
478
- test_presets .append (cluster . Structs . PresetStruct ( presetHandle = random . randbytes ( 16 ), presetScenario = cluster .Enums .PresetScenarioEnum .kWake ,
479
- name = "Wake" , coolingSetpoint = coolSetpoint , heatingSetpoint = heatSetpoint , builtIn = True ))
510
+ test_presets .append (self . make_preset ( cluster .Enums .PresetScenarioEnum .kWake , coolSetpoint ,
511
+ heatSetpoint , presetHandle = random . randbytes ( 16 ), name = "Wake" , builtIn = True ))
480
512
481
513
status = await self .write_presets (endpoint = endpoint , presets = test_presets , expected_status = Status .NotFound )
482
514
@@ -497,8 +529,8 @@ async def test_TC_TSTAT_4_2(self):
497
529
await self .send_atomic_request_begin_command ()
498
530
499
531
# Write to the presets attribute after adding a duplicate preset
500
- test_presets .append (cluster . Structs . PresetStruct (
501
- presetHandle = duplicatePreset . presetHandle , presetScenario = availableScenario , coolingSetpoint = coolSetpoint , heatingSetpoint = heatSetpoint , builtIn = False ))
532
+ test_presets .append (self . make_preset ( availableScenario , coolSetpoint ,
533
+ heatSetpoint , presetHandle = duplicatePreset . presetHandle ))
502
534
503
535
await self .write_presets (endpoint = endpoint , presets = test_presets , expected_status = Status .ConstraintError )
504
536
@@ -540,8 +572,7 @@ async def test_TC_TSTAT_4_2(self):
540
572
presets_without_name_support = list (preset for preset in test_presets if preset .presetScenario in availableScenarios )
541
573
542
574
if len (presets_without_name_support ) == 0 and len (availableScenarios ) > 0 :
543
- new_preset = cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = availableScenarios [0 ],
544
- coolingSetpoint = coolSetpoint , heatingSetpoint = heatSetpoint , builtIn = True )
575
+ new_preset = self .make_preset (availableScenarios [0 ], coolSetpoint , heatSetpoint , builtIn = True )
545
576
test_presets .append (new_preset )
546
577
presets_without_name_support = [new_preset ]
547
578
@@ -570,8 +601,7 @@ async def test_TC_TSTAT_4_2(self):
570
601
571
602
# Write to the presets attribute with a new valid preset added
572
603
test_presets = copy .deepcopy (current_presets )
573
- test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = availableScenario ,
574
- coolingSetpoint = coolSetpoint , heatingSetpoint = heatSetpoint , builtIn = False ))
604
+ test_presets .append (self .make_preset (availableScenario , coolSetpoint , heatSetpoint ))
575
605
576
606
# Send the AtomicRequest begin command
577
607
await self .send_atomic_request_begin_command ()
@@ -630,8 +660,7 @@ async def test_TC_TSTAT_4_2(self):
630
660
presetScenario for presetScenario in cluster .Enums .PresetScenarioEnum if presetScenario not in supportedScenarios )
631
661
if len (unavailableScenarios ) > 0 :
632
662
test_presets = current_presets .copy ()
633
- test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = unavailableScenarios [0 ],
634
- name = "Preset" , coolingSetpoint = coolSetpoint , heatingSetpoint = heatSetpoint , builtIn = False ))
663
+ test_presets .append (self .make_preset (unavailableScenarios [0 ], coolSetpoint , heatSetpoint , name = "Preset" ))
635
664
636
665
# Send the AtomicRequest begin command
637
666
await self .send_atomic_request_begin_command ()
@@ -664,8 +693,7 @@ async def test_TC_TSTAT_4_2(self):
664
693
presetsAddedForScenario = presetsAddedForScenario + 1
665
694
666
695
while presetsAddedForScenario < presetType .numberOfPresets :
667
- testPresets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = scenario ,
668
- coolingSetpoint = coolSetpoint , heatingSetpoint = heatSetpoint , builtIn = False ))
696
+ testPresets .append (self .make_preset (scenario , coolSetpoint , heatSetpoint ))
669
697
presetsAddedForScenario = presetsAddedForScenario + 1
670
698
671
699
# Send the AtomicRequest begin command
0 commit comments