diff --git a/homeassistant/components/light/tplink.py b/homeassistant/components/light/tplink.py index 669901f5b57..9374c1418f0 100644 --- a/homeassistant/components/light/tplink.py +++ b/homeassistant/components/light/tplink.py @@ -140,8 +140,6 @@ class TPLinkSmartBulb(Light): """Update the TP-Link Bulb's state.""" from pyHS100 import SmartDeviceException try: - self._available = True - if self._supported_features == 0: self.get_features() @@ -182,9 +180,13 @@ class TPLinkSmartBulb(Light): # device returned no daily/monthly history pass + self._available = True + except (SmartDeviceException, OSError) as ex: - _LOGGER.warning("Could not read state for %s: %s", self._name, ex) - self._available = False + if self._available: + _LOGGER.warning( + "Could not read state for %s: %s", self._name, ex) + self._available = False @property def supported_features(self): diff --git a/homeassistant/components/switch/tplink.py b/homeassistant/components/switch/tplink.py index eb54e7982a7..0cacdfe1539 100644 --- a/homeassistant/components/switch/tplink.py +++ b/homeassistant/components/switch/tplink.py @@ -87,8 +87,6 @@ class SmartPlugSwitch(SwitchDevice): """Update the TP-Link switch's state.""" from pyHS100 import SmartDeviceException try: - self._available = True - self._state = self.smartplug.state == \ self.smartplug.SWITCH_STATE_ON @@ -121,6 +119,10 @@ class SmartPlugSwitch(SwitchDevice): # Device returned no daily history pass + self._available = True + except (SmartDeviceException, OSError) as ex: - _LOGGER.warning("Could not read state for %s: %s", self.name, ex) - self._available = False + if self._available: + _LOGGER.warning( + "Could not read state for %s: %s", self.name, ex) + self._available = False