Fix switch.tplink doing I/O in event bus (#5589)

* Fix switch.tplink doing I/O in event bus

* Update tplink.py
This commit is contained in:
Paulus Schoutsen 2017-01-27 22:45:57 -08:00 committed by GitHub
parent b732174def
commit b4c3de3215

View file

@ -66,7 +66,7 @@ class SmartPlugSwitch(SwitchDevice):
@property
def is_on(self):
"""Return true if switch is on."""
return self.smartplug.is_on
return self._state
def turn_on(self, **kwargs):
"""Turn the switch on."""
@ -84,7 +84,8 @@ class SmartPlugSwitch(SwitchDevice):
def update(self):
"""Update the TP-Link switch's state."""
try:
self._state = self.smartplug.state
self._state = self.smartplug.state == \
self.smartplug.SWITCH_STATE_ON
if self.smartplug.has_emeter:
emeter_readings = self.smartplug.get_emeter_realtime()