Eliminate evohome unhandled exceptions when client API call fails (#43681)

This commit is contained in:
David Bonnes 2020-11-27 11:05:51 +00:00 committed by GitHub
parent 3a17e22cfa
commit bb146680ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -34,7 +34,7 @@ from homeassistant.helpers.service import verify_domain_control
from homeassistant.helpers.typing import ConfigType, HomeAssistantType from homeassistant.helpers.typing import ConfigType, HomeAssistantType
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from .const import DOMAIN, EVO_FOLLOW, GWS, STORAGE_KEY, STORAGE_VER, TCS, UTC_OFFSET from .const import DOMAIN, GWS, STORAGE_KEY, STORAGE_VER, TCS, UTC_OFFSET
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -628,8 +628,8 @@ class EvoChild(EvoDevice):
dt_aware = dt_naive.replace(tzinfo=dt_util.UTC) - utc_offset dt_aware = dt_naive.replace(tzinfo=dt_util.UTC) - utc_offset
return dt_util.as_local(dt_aware) return dt_util.as_local(dt_aware)
if not self._schedule["DailySchedules"]: if not self._schedule or not self._schedule.get("DailySchedules"):
return {} # no schedule {'DailySchedules': []}, so no scheduled setpoints return {} # no scheduled setpoints when {'DailySchedules': []}
day_time = dt_util.now() day_time = dt_util.now()
day_of_week = day_time.weekday() # for evohome, 0 is Monday day_of_week = day_time.weekday() # for evohome, 0 is Monday
@ -679,10 +679,6 @@ class EvoChild(EvoDevice):
async def _update_schedule(self) -> None: async def _update_schedule(self) -> None:
"""Get the latest schedule, if any.""" """Get the latest schedule, if any."""
if "DailySchedules" in self._schedule and not self._schedule["DailySchedules"]:
if not self._evo_device.setpointStatus["setpointMode"] == EVO_FOLLOW:
return # avoid unnecessary I/O - there's nothing to update
self._schedule = await self._evo_broker.call_client_api( self._schedule = await self._evo_broker.call_client_api(
self._evo_device.schedule(), update_state=False self._evo_device.schedule(), update_state=False
) )