switch.tplink: catch exceptions coming from pyHS100 to avoid flooding the logs when the plug is not available (#6400)

This commit is contained in:
Teemu R 2017-03-05 08:44:34 +01:00 committed by Daniel Høyer Iversen
parent c0bf3d7f32
commit 96aae1292b

View File

@ -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)