Reduce log spam (#33592)

* Reduce log spam

* Reduce log spam

* Revert
This commit is contained in:
cgtobi 2020-04-03 23:01:24 +02:00 committed by GitHub
parent f1d3c0d19b
commit 851c1711d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 10 deletions

View File

@ -386,11 +386,12 @@ class NetatmoThermostat(ClimateDevice):
) )
self._connected = True self._connected = True
except KeyError as err: except KeyError as err:
_LOGGER.debug( if self._connected is not False:
"The thermostat in room %s seems to be out of reach. (%s)", _LOGGER.debug(
self._room_name, "The thermostat in room %s seems to be out of reach. (%s)",
err, self._room_name,
) err,
)
self._connected = False self._connected = False
self._away = self._hvac_mode == HVAC_MAP_NETATMO[STATE_NETATMO_AWAY] self._away = self._hvac_mode == HVAC_MAP_NETATMO[STATE_NETATMO_AWAY]

View File

@ -220,6 +220,11 @@ class NetatmoSensor(Entity):
"""Return the unique ID for this sensor.""" """Return the unique ID for this sensor."""
return self._unique_id return self._unique_id
@property
def available(self):
"""Return True if entity is available."""
return bool(self._state)
def update(self): def update(self):
"""Get the latest data from Netatmo API and updates the states.""" """Get the latest data from Netatmo API and updates the states."""
self.netatmo_data.update() self.netatmo_data.update()
@ -233,10 +238,11 @@ class NetatmoSensor(Entity):
data = self.netatmo_data.data.get(self._module_id) data = self.netatmo_data.data.get(self._module_id)
if data is None: if data is None:
_LOGGER.debug( if self._state:
"No data found for %s (%s)", self.module_name, self._module_id _LOGGER.debug(
) "No data found for %s (%s)", self.module_name, self._module_id
_LOGGER.debug("data: %s", self.netatmo_data.data) )
_LOGGER.debug("data: %s", self.netatmo_data.data)
self._state = None self._state = None
return return
@ -391,7 +397,8 @@ class NetatmoSensor(Entity):
elif data["health_idx"] == 4: elif data["health_idx"] == 4:
self._state = "Unhealthy" self._state = "Unhealthy"
except KeyError: except KeyError:
_LOGGER.info("No %s data found for %s", self.type, self.module_name) if self._state:
_LOGGER.info("No %s data found for %s", self.type, self.module_name)
self._state = None self._state = None
return return