mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
Move TP-Link socket LED state setting to update() (#12170)
* Add error handling to TP-LInk LED state set Handles errors when setting the LED state of TP-Link sockets. If the socket is unavailable then the raised exception will cause the compoent to not be added to HA. * Move LED state setting out of __init__
This commit is contained in:
parent
cff4f8ec9a
commit
ec201f3458
@ -50,8 +50,7 @@ class SmartPlugSwitch(SwitchDevice):
|
||||
"""Initialize the switch."""
|
||||
self.smartplug = smartplug
|
||||
self._name = name
|
||||
if leds_on is not None:
|
||||
self.smartplug.led = leds_on
|
||||
self._leds_on = leds_on
|
||||
self._state = None
|
||||
self._available = True
|
||||
# Set up emeter cache
|
||||
@ -94,6 +93,10 @@ class SmartPlugSwitch(SwitchDevice):
|
||||
self._state = self.smartplug.state == \
|
||||
self.smartplug.SWITCH_STATE_ON
|
||||
|
||||
if self._leds_on is not None:
|
||||
self.smartplug.led = self._leds_on
|
||||
self._leds_on = None
|
||||
|
||||
# Pull the name from the device if a name was not specified
|
||||
if self._name == DEFAULT_NAME:
|
||||
self._name = self.smartplug.alias
|
||||
|
Loading…
x
Reference in New Issue
Block a user