diff --git a/src/bsblan/models.py b/src/bsblan/models.py index ac6ca63c..33812a14 100644 --- a/src/bsblan/models.py +++ b/src/bsblan/models.py @@ -216,6 +216,7 @@ class DataType(IntEnum): DATE = 6 # Day and month STRING = 7 # String value PPS_TIME = 8 # PPS time (day of week, hour:minute) + TIMEPROG = 9 # Time program (schedule slots) def _convert_bsblan_value( @@ -528,6 +529,15 @@ class HotWaterSchedule(BaseModel): This class contains time program settings that are typically configured once and rarely changed. + The daily time programs (Monday-Sunday) use BSB-LAN dataType 9 + (TIMEPROG) and return schedule strings like + ``"13:00-15:00 ##:##-##:## ##:##-##:##"`` where ``##:##`` marks + unused time slots. + + ``dhw_time_program_standard_values`` is a YESNO enum (0=No, 1=Yes) + that resets all daily schedules back to the controller's factory + defaults when set to Yes. It is typically read-only via the API. + Note: This is for READING from the device. For WRITING time programs, use SetHotWaterParam with set_hot_water(). @@ -541,6 +551,7 @@ class HotWaterSchedule(BaseModel): dhw_time_program_friday: EntityInfo[str | int] | None = None dhw_time_program_saturday: EntityInfo[str | int] | None = None dhw_time_program_sunday: EntityInfo[str | int] | None = None + # YESNO enum: resets all daily schedules to factory defaults when Yes (1) dhw_time_program_standard_values: EntityInfo[int] | None = None diff --git a/tests/test_entity_info.py b/tests/test_entity_info.py index e535630e..323bd61d 100644 --- a/tests/test_entity_info.py +++ b/tests/test_entity_info.py @@ -222,3 +222,44 @@ def test_entity_info_string_plain_text_not_parsed() -> None: assert entity.value == "1.0.38-20200730" assert entity.unit == "" + + +def test_entity_info_timeprog_schedule_string() -> None: + """Test TIMEPROG value with active and unused slots is kept as string.""" + entity = EntityInfo( + name="Monday", + value="13:00-15:00 ##:##-##:## ##:##-##:##", + unit="", + desc="", + data_type=DataType.TIMEPROG, + ) + + assert entity.value == "13:00-15:00 ##:##-##:## ##:##-##:##" + assert entity.data_type == DataType.TIMEPROG + + +def test_entity_info_timeprog_multiple_slots() -> None: + """Test TIMEPROG value with multiple active time slots.""" + entity = EntityInfo( + name="Tuesday", + value="06:00-08:00 17:00-21:00 ##:##-##:##", + unit="", + desc="", + data_type=DataType.TIMEPROG, + ) + + assert entity.value == "06:00-08:00 17:00-21:00 ##:##-##:##" + assert entity.data_type == DataType.TIMEPROG + + +def test_entity_info_timeprog_inactive() -> None: + """Test TIMEPROG with '---' (inactive/not in use) returns None.""" + entity = EntityInfo( + name="Sunday", + value="---", + unit="", + desc="", + data_type=DataType.TIMEPROG, + ) + + assert entity.value is None