From b3a08d587691f5e6dadfbc111b7cfc05a5bc0922 Mon Sep 17 00:00:00 2001 From: "Jarle B. Hjortand" Date: Fri, 11 Jan 2019 19:55:55 +0100 Subject: [PATCH] When tradfri experience communication errors make the lights/devices unavailable. (#19288) --- homeassistant/components/light/tradfri.py | 2 ++ homeassistant/components/switch/tradfri.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/homeassistant/components/light/tradfri.py b/homeassistant/components/light/tradfri.py index a26a2eb828a..50e92f15e3c 100644 --- a/homeassistant/components/light/tradfri.py +++ b/homeassistant/components/light/tradfri.py @@ -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) diff --git a/homeassistant/components/switch/tradfri.py b/homeassistant/components/switch/tradfri.py index 74997332b07..b247858b062 100644 --- a/homeassistant/components/switch/tradfri.py +++ b/homeassistant/components/switch/tradfri.py @@ -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)