@@ -413,8 +413,10 @@ def mock_read(attributes, manufacturer=None):
413
413
)
414
414
415
415
416
- async def test_bosch_radiator_thermostat_II_read_attributes (zigpy_device_from_v2_quirk ):
417
- """Test the Radiator Thermostat II reads behaving correctly."""
416
+ async def test_bosch_radiator_thermostat_II_read_attributes_paused (
417
+ zigpy_device_from_v2_quirk ,
418
+ ):
419
+ """Test the Radiator Thermostat II reads behaving correctly when paused."""
418
420
419
421
device = zigpy_device_from_v2_quirk (manufacturer = "BOSCH" , model = "RBSH-TRV0-ZB-EU" )
420
422
@@ -458,6 +460,110 @@ def mock_read(attributes, manufacturer=None):
458
460
assert Thermostat .SystemMode .Off in success .values ()
459
461
460
462
463
+ async def test_bosch_radiator_thermostat_II_read_attributes_manual_heat (
464
+ zigpy_device_from_v2_quirk ,
465
+ ):
466
+ """Test the Radiator Thermostat II reads behaving correctly when heat is enabled."""
467
+
468
+ device = zigpy_device_from_v2_quirk (manufacturer = "BOSCH" , model = "RBSH-TRV0-ZB-EU" )
469
+
470
+ bosch_thermostat_cluster = device .endpoints [1 ].thermostat
471
+
472
+ # fake read response for attributes: return BoschOperatingMode.Manual/ControlSequenceOfOperation.Heating_Only for all attributes
473
+ def mock_read (attributes , manufacturer = None ):
474
+ records = [
475
+ foundation .ReadAttributeRecord (
476
+ attr ,
477
+ foundation .Status .SUCCESS ,
478
+ foundation .TypeValue (
479
+ None ,
480
+ BoschOperatingMode .Manual
481
+ if attr == BoschTrvThermostatCluster .AttributeDefs .operating_mode .id
482
+ else ControlSequenceOfOperation .Heating_Only ,
483
+ ),
484
+ )
485
+ for attr in attributes
486
+ ]
487
+ return (records ,)
488
+
489
+ # data is read from trv
490
+ patch_bosch_trv_read = mock .patch .object (
491
+ bosch_thermostat_cluster ,
492
+ "_read_attributes" ,
493
+ mock .AsyncMock (side_effect = mock_read ),
494
+ )
495
+
496
+ # check that system_mode ends-up reading operating_mode and ControlSequenceOfOperation:
497
+ with patch_bosch_trv_read :
498
+ # - system_mode by id
499
+ success , fail = await bosch_thermostat_cluster .read_attributes (
500
+ [Thermostat .AttributeDefs .system_mode .id ]
501
+ )
502
+ assert success
503
+ assert not fail
504
+ assert Thermostat .SystemMode .Heat in success .values ()
505
+
506
+ # - system_mode by name
507
+ success , fail = await bosch_thermostat_cluster .read_attributes (
508
+ [Thermostat .AttributeDefs .system_mode .name ]
509
+ )
510
+ assert success
511
+ assert not fail
512
+ assert Thermostat .SystemMode .Heat in success .values ()
513
+
514
+
515
+ async def test_bosch_radiator_thermostat_II_read_attributes_manual_cool (
516
+ zigpy_device_from_v2_quirk ,
517
+ ):
518
+ """Test the Radiator Thermostat II reads behaving correctly when cooling is enabled."""
519
+
520
+ device = zigpy_device_from_v2_quirk (manufacturer = "BOSCH" , model = "RBSH-TRV0-ZB-EU" )
521
+
522
+ bosch_thermostat_cluster = device .endpoints [1 ].thermostat
523
+
524
+ # fake read response for attributes: return BoschOperatingMode.Manual/ControlSequenceOfOperation.Cooling_Only for all attributes
525
+ def mock_read (attributes , manufacturer = None ):
526
+ records = [
527
+ foundation .ReadAttributeRecord (
528
+ attr ,
529
+ foundation .Status .SUCCESS ,
530
+ foundation .TypeValue (
531
+ None ,
532
+ BoschOperatingMode .Manual
533
+ if attr == BoschTrvThermostatCluster .AttributeDefs .operating_mode .id
534
+ else ControlSequenceOfOperation .Cooling_Only ,
535
+ ),
536
+ )
537
+ for attr in attributes
538
+ ]
539
+ return (records ,)
540
+
541
+ # data is read from trv
542
+ patch_bosch_trv_read = mock .patch .object (
543
+ bosch_thermostat_cluster ,
544
+ "_read_attributes" ,
545
+ mock .AsyncMock (side_effect = mock_read ),
546
+ )
547
+
548
+ # check that system_mode ends-up reading operating_mode and ControlSequenceOfOperation:
549
+ with patch_bosch_trv_read :
550
+ # - system_mode by id
551
+ success , fail = await bosch_thermostat_cluster .read_attributes (
552
+ [Thermostat .AttributeDefs .system_mode .id ]
553
+ )
554
+ assert success
555
+ assert not fail
556
+ assert Thermostat .SystemMode .Cool in success .values ()
557
+
558
+ # - system_mode by name
559
+ success , fail = await bosch_thermostat_cluster .read_attributes (
560
+ [Thermostat .AttributeDefs .system_mode .name ]
561
+ )
562
+ assert success
563
+ assert not fail
564
+ assert Thermostat .SystemMode .Cool in success .values ()
565
+
566
+
461
567
async def test_bosch_room_thermostat_II_230v_write_attributes (
462
568
zigpy_device_from_v2_quirk ,
463
569
):
0 commit comments