From 96aae1292b76d9d06febf9f71e1284049831c665 Mon Sep 17 00:00:00 2001 From: Teemu R Date: Sun, 5 Mar 2017 08:44:34 +0100 Subject: [PATCH] switch.tplink: catch exceptions coming from pyHS100 to avoid flooding the logs when the plug is not available (#6400) --- homeassistant/components/switch/tplink.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/switch/tplink.py b/homeassistant/components/switch/tplink.py index 961ee72496e..f740a5f1614 100644 --- a/homeassistant/components/switch/tplink.py +++ b/homeassistant/components/switch/tplink.py @@ -83,6 +83,7 @@ class SmartPlugSwitch(SwitchDevice): def update(self): """Update the TP-Link switch's state.""" + from pyHS100 import SmartPlugException try: self._state = self.smartplug.state == \ self.smartplug.SWITCH_STATE_ON @@ -107,5 +108,5 @@ class SmartPlugSwitch(SwitchDevice): # device returned no daily history pass - except OSError: - _LOGGER.warning('Could not update status for %s', self.name) + except (SmartPlugException, OSError) as ex: + _LOGGER.warning('Could not read state for %s: %s', self.name, ex)