bugfix evohome and bump client (#27968)

* bump client to 0.3.4b1

* handle bad schedules that cause issue #27768
This commit is contained in:
David Bonnes 2019-10-20 17:51:08 +01:00 committed by GitHub
parent 22b29a8005
commit 425e7fd1a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 28 deletions

View file

@ -460,37 +460,44 @@ class EvoChild(EvoDevice):
day_of_week = int(day_time.strftime("%w")) # 0 is Sunday day_of_week = int(day_time.strftime("%w")) # 0 is Sunday
time_of_day = day_time.strftime("%H:%M:%S") time_of_day = day_time.strftime("%H:%M:%S")
# Iterate today's switchpoints until past the current time of day... try:
day = self._schedule["DailySchedules"][day_of_week] # Iterate today's switchpoints until past the current time of day...
sp_idx = -1 # last switchpoint of the day before day = self._schedule["DailySchedules"][day_of_week]
for i, tmp in enumerate(day["Switchpoints"]): sp_idx = -1 # last switchpoint of the day before
if time_of_day > tmp["TimeOfDay"]: for i, tmp in enumerate(day["Switchpoints"]):
sp_idx = i # current setpoint if time_of_day > tmp["TimeOfDay"]:
else: sp_idx = i # current setpoint
break else:
break
# Did the current SP start yesterday? Does the next start SP tomorrow? # Did the current SP start yesterday? Does the next start SP tomorrow?
this_sp_day = -1 if sp_idx == -1 else 0 this_sp_day = -1 if sp_idx == -1 else 0
next_sp_day = 1 if sp_idx + 1 == len(day["Switchpoints"]) else 0 next_sp_day = 1 if sp_idx + 1 == len(day["Switchpoints"]) else 0
for key, offset, idx in [ for key, offset, idx in [
("this", this_sp_day, sp_idx), ("this", this_sp_day, sp_idx),
("next", next_sp_day, (sp_idx + 1) * (1 - next_sp_day)), ("next", next_sp_day, (sp_idx + 1) * (1 - next_sp_day)),
]: ]:
sp_date = (day_time + timedelta(days=offset)).strftime("%Y-%m-%d") sp_date = (day_time + timedelta(days=offset)).strftime("%Y-%m-%d")
day = self._schedule["DailySchedules"][(day_of_week + offset) % 7] day = self._schedule["DailySchedules"][(day_of_week + offset) % 7]
switchpoint = day["Switchpoints"][idx] switchpoint = day["Switchpoints"][idx]
dt_local_aware = _local_dt_to_aware( dt_local_aware = _local_dt_to_aware(
dt_util.parse_datetime(f"{sp_date}T{switchpoint['TimeOfDay']}") dt_util.parse_datetime(f"{sp_date}T{switchpoint['TimeOfDay']}")
)
self._setpoints[f"{key}_sp_from"] = dt_local_aware.isoformat()
try:
self._setpoints[f"{key}_sp_temp"] = switchpoint["heatSetpoint"]
except KeyError:
self._setpoints[f"{key}_sp_state"] = switchpoint["DhwState"]
except IndexError:
self._setpoints = {}
_LOGGER.warning(
"Failed to get setpoints - please report as an issue", exc_info=True
) )
self._setpoints[f"{key}_sp_from"] = dt_local_aware.isoformat()
try:
self._setpoints[f"{key}_sp_temp"] = switchpoint["heatSetpoint"]
except KeyError:
self._setpoints[f"{key}_sp_state"] = switchpoint["DhwState"]
return self._setpoints return self._setpoints
async def _update_schedule(self) -> None: async def _update_schedule(self) -> None:

View file

@ -3,7 +3,7 @@
"name": "Evohome", "name": "Evohome",
"documentation": "https://www.home-assistant.io/integrations/evohome", "documentation": "https://www.home-assistant.io/integrations/evohome",
"requirements": [ "requirements": [
"evohome-async==0.3.3b5" "evohome-async==0.3.4b1"
], ],
"dependencies": [], "dependencies": [],
"codeowners": ["@zxdavb"] "codeowners": ["@zxdavb"]

View file

@ -480,7 +480,7 @@ eternalegypt==0.0.10
# evdev==0.6.1 # evdev==0.6.1
# homeassistant.components.evohome # homeassistant.components.evohome
evohome-async==0.3.3b5 evohome-async==0.3.4b1
# homeassistant.components.dlib_face_detect # homeassistant.components.dlib_face_detect
# homeassistant.components.dlib_face_identify # homeassistant.components.dlib_face_identify