Skip to content

Commit

Permalink
Add dhw desired temperature
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyfx1 committed Mar 28, 2020
1 parent 7801bd9 commit 7a10533
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions PyViCare/PyViCareDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
import json
import os
import logging
from datetime import datetime, time
from PyViCare.PyViCareService import ViCareService
from PyViCare.PyViCareCachedService import ViCareCachedService

logger = logging.getLogger('ViCare')
logger.addHandler(logging.NullHandler())

VICARE_DAYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"]
VICARE_DHW_TEMP2 = "temp-2"

# TODO Holiday program can still be used (parameters are there) heating.circuits." + str(self.service.circuit) + ".operating.programs.holiday
# TODO heating.dhw.schedule/setSchedule
# https://api.viessmann-platform.io/operational-data/installations/16011/gateways/7571381681420106/devices/0/features
Expand Down Expand Up @@ -212,12 +216,54 @@ def getActiveError(self):
return self.service.getProperty("heating.errors.active")["properties"]["entries"]["value"]
except KeyError:
return "error"

def getDomesticHotWaterConfiguredTemperature(self):
try:
return self.service.getProperty("heating.dhw.temperature")["properties"]["value"]["value"]
except KeyError:
return "error"

def getDomesticHotWaterConfiguredTemperature2(self):
try:
return self.service.getProperty("heating.dhw.temperature.temp2")["properties"]["value"]["value"]
except KeyError:
return "error"

def getDomesticHotWaterActiveMode(self):
schedule = self.getDomesticHotWaterSchedule()
if schedule == "error" or schedule["active"] != True:
return None

currentDateTime = datetime.now()
currentTime = currentDateTime.time()

try:
daySchedule = schedule[VICARE_DAYS[currentDateTime.weekday()]]
except KeyError: # no schedule for day configured
return None

tempMode = None
for s in daySchedule:
startTime = time.fromisoformat(s["start"])
endTime = time.fromisoformat(s["end"])
if startTime <= currentTime and currentTime <= endTime:
if s["mode"] == VICARE_DHW_TEMP2: # temp-2 overrides all other modes
return s["mode"]
else:
mode = s["mode"]
return mode

def getDomesticHotWaterDesiredTemperature(self):
mode = self.getDomesticHotWaterActiveMode()

if mode != None:
if mode == VICARE_DHW_TEMP2:
return self.getDomesticHotWaterConfiguredTemperature2()
else:
return self.getDomesticHotWaterConfiguredTemperature()

return None

def getDomesticHotWaterStorageTemperature(self):
try:
return self.service.getProperty("heating.dhw.sensors.temperature.hotWaterStorage")["properties"]["value"]["value"]
Expand Down

0 comments on commit 7a10533

Please sign in to comment.