Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schedules for getting #117

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
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
26 changes: 26 additions & 0 deletions evohomeclient2/controlsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ def temperatures(self):
"name": "",
"temp": self.hotwater.temperatureStatus["temperature"],
"setpoint": "",
"setpointmode": "",
"setpointend": "1970-01-01T00:00:00Z",
"activefaults": self.hotwater.activeFaults,
}

for zone in self._zones:
Expand All @@ -120,12 +123,35 @@ def temperatures(self):
"name": zone.name,
"temp": None,
"setpoint": zone.setpointStatus["targetHeatTemperature"],
"setpointmode": zone.setpointStatus["setpointMode"],
"setpointend": "1970-01-01T00:00:00Z",
"activefaults": zone.activeFaults,
}

if zone.temperatureStatus["isAvailable"]:
zone_info["temp"] = zone.temperatureStatus["temperature"]
if zone.setpointStatus.get("until"):
zone_info["setpointend"] = zone.setpointStatus["until"]
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