@@ -467,17 +467,38 @@ async def test_TC_TSTAT_4_2(self):
467
467
468
468
self .step ("17" )
469
469
if self .pics_guard (self .check_pics ("TSTAT.S.F08" ) and self .check_pics ("TSTAT.S.A0050" ) and self .check_pics ("TSTAT.S.Cfe.Rsp" )):
470
- test_presets = new_presets_with_handle .copy ()
471
- test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = cluster .Enums .PresetScenarioEnum .kGoingToSleep ,
472
- name = "Wake" , coolingSetpoint = 2500 , heatingSetpoint = 1700 , builtIn = False ))
473
470
474
- # Send the AtomicRequest begin command
475
- await self .send_atomic_request_begin_command ( )
471
+ # Read the PresetTypes to get the preset scenarios supported by the Thermostat.
472
+ presetTypes = await self .read_single_attribute_check_success ( endpoint = endpoint , cluster = cluster , attribute = cluster . Attributes . PresetTypes )
476
473
477
- await self . write_presets ( endpoint = endpoint , presets = test_presets , expected_status = Status . ConstraintError )
474
+ scenarioNotPresent = None
478
475
479
- # Clear state for next test.
480
- await self .send_atomic_request_rollback_command ()
476
+ # Find a preset scenario not present in PresetTypes to run this test.
477
+ for scenario in cluster .Enums .PresetScenarioEnum :
478
+ foundMatchingScenario = False
479
+ for presetType in presetTypes :
480
+ if presetType .presetScenario == scenario :
481
+ foundMatchingScenario = True
482
+ break
483
+ if foundMatchingScenario == False :
484
+ scenarioNotPresent = scenario
485
+ break
486
+
487
+ if scenarioNotPresent == None :
488
+ logger .info (
489
+ "Couldn't run test step 17 since all preset types in PresetScenarioEnum are supported by this Thermostat" )
490
+ else :
491
+ test_presets = new_presets_with_handle .copy ()
492
+ test_presets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = scenarioNotPresent ,
493
+ name = "Preset" , coolingSetpoint = 2500 , heatingSetpoint = 1700 , builtIn = False ))
494
+
495
+ # Send the AtomicRequest begin command
496
+ await self .send_atomic_request_begin_command ()
497
+
498
+ await self .write_presets (endpoint = endpoint , presets = test_presets , expected_status = Status .ConstraintError )
499
+
500
+ # Clear state for next test.
501
+ await self .send_atomic_request_rollback_command ()
481
502
482
503
self .step ("18" )
483
504
if self .pics_guard (self .check_pics ("TSTAT.S.F08" ) and self .check_pics ("TSTAT.S.A0050" ) and self .check_pics ("TSTAT.S.Cfe.Rsp" )):
@@ -501,18 +522,18 @@ async def test_TC_TSTAT_4_2(self):
501
522
for presetType in presetTypes :
502
523
scenario = presetType .presetScenario
503
524
504
- # For each scenario, copy all the existing presets that match it, then add more presets
525
+ # For each supported scenario, copy all the existing presets that match it, then add more presets
505
526
# until we hit the cap on the number of presets for that scenario.
506
527
presetsAddedForScenario = 0
507
528
for preset in presets :
508
529
if scenario == preset .presetScenario :
509
530
testPresets .append (preset )
510
- + + presetsAddedForScenario
531
+ presetsAddedForScenario = presetsAddedForScenario + 1
511
532
512
- while presetsAddedForScenario < presetType .numberOfPresets :
513
- testPresets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = scenario ,
514
- name = "Preset" , coolingSetpoint = 2500 , heatingSetpoint = 1700 , builtIn = False ))
515
- + + presetsAddedForScenario
533
+ if presetsAddedForScenario < presetType .numberOfPresets :
534
+ testPresets .append (cluster .Structs .PresetStruct (presetHandle = NullValue , presetScenario = scenario ,
535
+ name = "Preset" , coolingSetpoint = 2500 , heatingSetpoint = 1700 , builtIn = False ))
536
+ presetsAddedForScenario = presetsAddedForScenario + 1
516
537
517
538
# Send the AtomicRequest begin command
518
539
await self .send_atomic_request_begin_command ()
0 commit comments