Catch garmin_connect keyerrors with unknown entity type updates (#31608)

* Catch keyerrors with unknown entity type updates

* Change debug level and removed . from log call
pull/31645/head^2
Ron Klinkien 2020-02-08 18:47:54 +01:00 committed by GitHub
parent 14e0dde055
commit 1093e25a30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View File

@ -256,21 +256,21 @@ GARMIN_ENTITY_LIST = {
"brpm",
"mdi:progress-clock",
None,
True,
False,
],
"lowestRespirationValue": [
"Lowest Respiration",
"brpm",
"mdi:progress-clock",
None,
True,
False,
],
"latestRespirationValue": [
"Latest Respiration",
"brpm",
"mdi:progress-clock",
None,
True,
False,
],
"latestRespirationTimeGMT": [
"Latest Respiration Update",

View File

@ -165,12 +165,16 @@ class GarminConnectSensor(Entity):
return
data = self._data.data
if "Duration" in self._type and data[self._type]:
self._state = data[self._type] // 60
elif "Seconds" in self._type and data[self._type]:
self._state = data[self._type] // 60
else:
self._state = data[self._type]
try:
if "Duration" in self._type and data[self._type]:
self._state = data[self._type] // 60
elif "Seconds" in self._type and data[self._type]:
self._state = data[self._type] // 60
else:
self._state = data[self._type]
except KeyError:
_LOGGER.debug("Entity type %s not found in fetched data", self._type)
return
_LOGGER.debug(
"Entity %s set to state %s %s", self._type, self._state, self._unit