Fix geniushub spamming log with exceptions (#37067)

pull/37089/head
RogerSelwyn 2020-06-25 07:20:00 +01:00 committed by GitHub
parent f4528d0db2
commit 9137957cf9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -167,6 +167,7 @@ class GeniusBroker:
self.hass = hass
self.client = client
self._hub_uid = hub_uid
self._connect_error = False
@property
def hub_uid(self) -> int:
@ -178,8 +179,19 @@ class GeniusBroker:
"""Update the geniushub client's data."""
try:
await self.client.update()
except aiohttp.ClientResponseError as err:
_LOGGER.warning("Update failed, message is: %s", err)
if self._connect_error:
self._connect_error = False
_LOGGER.warning("Connection to geniushub re-established")
except (
aiohttp.ClientResponseError,
aiohttp.client_exceptions.ClientConnectorError,
) as err:
if not self._connect_error:
self._connect_error = True
_LOGGER.warning(
"Connection to geniushub failed (unable to update), message is: %s",
err,
)
return
self.make_debug_log_entries()
@ -240,7 +252,6 @@ class GeniusDevice(GeniusEntity):
@property
def device_state_attributes(self) -> Dict[str, Any]:
"""Return the device state attributes."""
attrs = {}
attrs["assigned_zone"] = self._device.data["assignedZones"][0]["name"]
if self._last_comms: