Skip to content

Commit

Permalink
Add schedules for getting
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeroen authored and Hout committed Dec 13, 2020
1 parent 9471c81 commit 945c019
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 88 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,7 @@ dmypy.json
.pytype/

test-reports/
test.py
test.py

# pipfile
Pipfile.lock
19 changes: 14 additions & 5 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
name = "pypi"

[packages]
requests = "*"
requests = "==2.23.0"

[dev-packages]
black = "==19.10b0"
flake8 = "==3.7.9"
isort = "==4.3.21"
pre-commit = "==2.1.1"
ptvsd = "==4.3.2"
pycodestyle = "==2.5.0"
pyflakes = "==2.1.1"
pylint = "==2.4.4"
requests = "==2.23.0"

[requires]
python_version = "3.6"
python_version = "3.9"
58 changes: 0 additions & 58 deletions Pipfile.lock

This file was deleted.

8 changes: 7 additions & 1 deletion evohomeclient2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ def _obtain_access_token(self, credentials):
}
payload.update(credentials) # merge the credentials into the payload

response = requests.post(url, data=payload, headers=HEADER_BASIC_AUTH, timeout=self.timeout)
response = requests.post(
url, data=payload, headers=HEADER_BASIC_AUTH, timeout=self.timeout
)

try:
response.raise_for_status()
Expand Down Expand Up @@ -312,6 +314,10 @@ def temperatures(self):
"""Return the current zone temperatures and set points."""
return self._get_single_heating_system().temperatures()

def schedules(self):
"""Return the current zone schedules."""
return self._get_single_heating_system().schedules()

def zone_schedules_backup(self, filename):
"""Back up the current system configuration to the given file."""
return self._get_single_heating_system().zone_schedules_backup(filename)
Expand Down
18 changes: 18 additions & 0 deletions evohomeclient2/controlsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ def temperatures(self):
zone_info["temp"] = zone.temperatureStatus["temperature"]
yield zone_info

def schedules(self):
"""Return a generator with the schedule of each zone."""
if self.hotwater:
_LOGGER.info("Retrieving DHW schedule: %s...", self.hotwater.zoneId)
yield {
"name": "Domestic Hot Water",
"id": self.hotwater.zoneId,
"schedule": self.hotwater.schedule(),
}

for zone in self._zones:
_LOGGER.info("Retrieving Zone schedule: %s - %s", zone.zoneId, zone.name)
yield {
"name": zone.name,
"id": zone.zoneId,
"schedule": zone.schedule(),
}

def zone_schedules_backup(self, filename):
"""Backup all zones on control system to the given file."""
_LOGGER.info(
Expand Down
57 changes: 35 additions & 22 deletions evohomeclient2/hotwater.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,67 +12,80 @@ class HotWater(ZoneBase):
def __init__(self, client, data, timeout=30):
super(HotWater, self).__init__(client, timeout)

self.dhwId = None # pylint: disable=invalid-name
self.dhwId = None # pylint: disable=invalid-name

self.__dict__.update(data)

self.name = ""
self.zoneId = self.dhwId
self.zone_type = 'domesticHotWater'
self.zone_type = "domesticHotWater"

def _set_dhw(self, data):
headers = dict(self.client._headers()) # pylint: disable=protected-access
headers['Content-Type'] = 'application/json'
headers = dict(self.client._headers()) # pylint: disable=protected-access
headers["Content-Type"] = "application/json"
url = (
"https://tccna.honeywell.com/WebAPI/emea/api/v1"
"/domesticHotWater/%s/state" % self.dhwId
)

response = requests.put(url, data=json.dumps(data), headers=headers, timeout=self.timeout)
response = requests.put(
url, data=json.dumps(data), headers=headers, timeout=self.timeout
)
response.raise_for_status()

def set_dhw_on(self, until=None):
"""Sets the DHW on until a given time, or permanently."""
if until is None:
data = {"Mode": "PermanentOverride",
"State": "On",
"UntilTime": None}
data = {
"Mode": "PermanentOverride",
"State": "On",
"UntilTime": None,
}
else:
data = {"Mode": "TemporaryOverride",
"State": "On",
"UntilTime": until.strftime('%Y-%m-%dT%H:%M:%SZ')}
data = {
"Mode": "TemporaryOverride",
"State": "On",
"UntilTime": until.strftime("%Y-%m-%dT%H:%M:%SZ"),
}

self._set_dhw(data)

def set_dhw_off(self, until=None):
"""Sets the DHW off until a given time, or permanently."""
if until is None:
data = {"Mode": "PermanentOverride",
"State": "Off",
"UntilTime": None}
data = {
"Mode": "PermanentOverride",
"State": "Off",
"UntilTime": None,
}
else:
data = {"Mode": "TemporaryOverride",
"State": "Off",
"UntilTime": until.strftime('%Y-%m-%dT%H:%M:%SZ')}
data = {
"Mode": "TemporaryOverride",
"State": "Off",
"UntilTime": until.strftime("%Y-%m-%dT%H:%M:%SZ"),
}

self._set_dhw(data)

def set_dhw_auto(self):
"""Sets the DHW to follow the schedule."""
data = {"Mode": "FollowSchedule",
"State": "",
"UntilTime": None}
data = {
"Mode": "FollowSchedule",
"State": "",
"UntilTime": None,
}

self._set_dhw(data)


def get_dhw_state(self):
"""Gets the DHW state."""
url = (
"https://tccna.honeywell.com/WebAPI/emea/api/v1/"
"domesticHotWater/%s/status?" % self.dhwId
)

response = requests.get( url, headers=self.client._headers(), timeout=self.timeout)
response = requests.get(
url, headers=self.client._headers(), timeout=self.timeout
)
data = response.json()
return data
4 changes: 3 additions & 1 deletion evohomeclient2/zone.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def _set_heat_setpoint(self, data):
headers = dict(self.client._headers())
headers["Content-Type"] = "application/json"

response = requests.put(url, json.dumps(data), headers=headers, timeout=self.timeout)
response = requests.put(
url, json.dumps(data), headers=headers, timeout=self.timeout
)
response.raise_for_status()

def cancel_temp_override(self):
Expand Down

0 comments on commit 945c019

Please sign in to comment.