When tradfri experience communication errors make the lights/devices unavailable. (#19288)

This commit is contained in:
Jarle B. Hjortand 2019-01-11 19:55:55 +01:00 committed by Paulus Schoutsen
parent e2f55a959f
commit b3a08d5876
2 changed files with 4 additions and 0 deletions

View file

@ -339,6 +339,8 @@ class TradfriLight(Light):
# pylint: disable=import-error
from pytradfri.error import PytradfriError
if exc:
self._available = False
self.async_schedule_update_ha_state()
_LOGGER.warning("Observation failed for %s", self._name,
exc_info=exc)

View file

@ -108,6 +108,8 @@ class TradfriSwitch(SwitchDevice):
"""Start observation of switch."""
from pytradfri.error import PytradfriError
if exc:
self._available = False
self.async_schedule_update_ha_state()
_LOGGER.warning("Observation failed for %s", self._name,
exc_info=exc)