Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
fix: handle empty day in time program
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasgermain committed Oct 18, 2023
1 parent 5ce17ba commit 2c132bf
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 1 deletion.
1 change: 1 addition & 0 deletions pymultimatic/model/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ def map_time_program(raw_time_program, key: Optional[str] = None) -> TimeProgram
def map_time_program_day(raw_time_program_day, key: Optional[str] = None) -> TimeProgramDay:
"""Map *time program day* and *time program day settings*."""
settings = []
time_program_day = None
if raw_time_program_day:
# By default in multimatic mode
multimatic_timeprogram = True
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="pymultiMATIC",
version="0.7.2",
version="0.7.3",
description="Python interface with Vaillant multiMATIC",
long_description_content_type="text/markdown",
long_description=long_description,
Expand Down
86 changes: 86 additions & 0 deletions tests/files/responses/dhws_empty_timeprogram_days.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"body": [
{
"hotwater": {
"configuration": {
"operation_mode": "AUTO",
"temperature_setpoint": 50.0
},
"timeprogram": {
"monday": [
],
"tuesday": [
],
"wednesday": [
],
"thursday": [
],
"friday": [
],
"saturday": [
],
"sunday": [
]
}
},
"circulation": {
"configuration": {
"operationMode": "AUTO"
},
"timeprogram": {
"monday": [
],
"tuesday": [
],
"wednesday": [
],
"thursday": [
],
"friday": [
],
"saturday": [
],
"sunday": [
]
}
},
"_id": "Control_DHW"
}
],
"meta": {
"resourceState": [
{
"state": "SYNCED",
"timestamp": 1624356098685,
"link": {
"rel": "self",
"resourceLink": "/facilities/xxxxx/systemcontrol/v1/dhw/Control_DHW/circulation/configuration"
}
},
{
"state": "SYNCED",
"timestamp": 1624348841011,
"link": {
"rel": "self",
"resourceLink": "/facilities/xxxxx/systemcontrol/v1/dhw/Control_DHW/hotwater/configuration"
}
},
{
"state": "SYNCED",
"timestamp": 1624355861000,
"link": {
"rel": "self",
"resourceLink": "/facilities/xxxxx/systemcontrol/v1/dhw/Control_DHW/circulation/timeprogram"
}
},
{
"state": "SYNCED",
"timestamp": 1624355861000,
"link": {
"rel": "self",
"resourceLink": "/facilities/xxxxx/systemcontrol/v1/dhw/Control_DHW/hotwater/timeprogram"
}
}
]
}
}
10 changes: 10 additions & 0 deletions tests/test_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ def test_map_dhw_empty_timeprogram(self) -> None:
self.assertIsNotNone(dhw.circulation.time_program)
self.assertIsNotNone(dhw.hotwater.time_program)

def test_map_dhw_empty_timeprogram_days(self) -> None:
with open(path("files/responses/dhws_empty_timeprogram_days"), "r") as file:
raw_dhw = json.loads(file.read())
dhw = mapper.map_dhw(raw_dhw)
self.assertIsNotNone(dhw.hotwater)
self.assertIsNotNone(dhw.circulation)
self.assertIsNotNone(dhw.circulation.time_program)
self.assertIsNotNone(dhw.hotwater.time_program)
self.assertIsNotNone(dhw.hotwater.active_mode)

def test_map_zone_cooling(self) -> None:
"""Test map zone with cooling."""
with open(path("files/responses/systemcontrol_ventilation"), "r") as file:
Expand Down

0 comments on commit 2c132bf

Please sign in to comment.