Skip to content
Open
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
10 changes: 10 additions & 0 deletions PyViCare/PyViCareHeatingDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,16 @@ def getHeatingSchedule(self):
"sun": properties["entries"]["value"]["sun"]
}

@handleAPICommandErrors
def setHeatingSchedule(self, schedule: dict) -> None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you add a test case for this as well, please.

self.service.setProperty(f"heating.circuits.{self.circuit}.heating.schedule",
"setSchedule", {'newSchedule': schedule})

@handleNotSupported
def getHeatingScheduleModes(self) -> list: # type: ignore[type-arg]
return list(self.getProperty(f"heating.circuits.{self.circuit}.heating.schedule"
)["commands"]["setSchedule"]["params"]["newSchedule"]["constraints"]["modes"])

# Calculates target supply temperature based on data from Viessmann
# See: https://www.viessmann-community.com/t5/Gas/Mathematische-Formel-fuer-Vorlauftemperatur-aus-den-vier/m-p/68890#M27556
def getTargetSupplyTemperature(self) -> Optional[float]:
Expand Down
25 changes: 25 additions & 0 deletions tests/test_Vitocal300G.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,3 +262,28 @@ def test_coolingCircuit_getType(self):
def test_coolingCircuit_getReverseActive(self):
self.assertEqual(
self.device.coolingCircuits[0].getReverseActive(), False)

def test_getHeatingScheduleModes(self):
expected_modes = {'reduced', 'normal', 'fixed'}
self.assertSetEqual(
set(self.device.circuits[0].getHeatingScheduleModes()), expected_modes)

def test_setHeatingSchedule(self):
schedule = {
"mon": [{"start": "06:00", "end": "22:00", "mode": "normal", "position": 0}],
"tue": [],
"wed": [],
"thu": [],
"fri": [],
"sat": [],
"sun": [],
}
self.device.circuits[0].setHeatingSchedule(schedule)
self.assertEqual(len(self.service.setPropertyData), 1)
self.assertEqual(
self.service.setPropertyData[0]['property_name'],
f'heating.circuits.{self.device.circuits[0].circuit}.heating.schedule')
self.assertEqual(
self.service.setPropertyData[0]['action'], 'setSchedule')
self.assertEqual(
self.service.setPropertyData[0]['data'], {'newSchedule': schedule})
Loading