Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/bsblan/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new TIMEPROG data type is added to the DataType enum but is not handled in the _convert_bsblan_value function (lines 222-269). This function has explicit handling for PLAIN_NUMBER, ENUM, TIME, and WEEKDAY types, but other types including STRING, PPS_TIME, and now TIMEPROG fall through to the default string handling. While this may be intentional (keeping time program strings as-is), it should be verified that TIMEPROG values don't require special parsing, or explicit handling should be added for clarity and consistency with the comment on line 219.

Copilot uses AI. Check for mistakes.


def _convert_bsblan_value(
Expand Down Expand Up @@ -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.
Comment on lines +532 to +535
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation claims that daily time programs use BSB-LAN dataType 9 (TIMEPROG), but the existing test fixture in test_hot_water_additional.py uses dataType 0 (PLAIN_NUMBER) for all schedule parameters (lines 153, 160, 167, 174, 181, 188, 195). This creates a discrepancy between the documentation and the test data. Either the test fixtures should be updated to use dataType 9, or the documentation should be corrected to reflect the actual dataType used by BSB-LAN devices for time program parameters.

Copilot uses AI. Check for mistakes.

``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().
Expand All @@ -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


Expand Down
41 changes: 41 additions & 0 deletions tests/test_entity_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading