mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 14:57:09 +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."""
|
"""Initialize the switch."""
|
||||||
self.smartplug = smartplug
|
self.smartplug = smartplug
|
||||||
self._name = name
|
self._name = name
|
||||||
if leds_on is not None:
|
self._leds_on = leds_on
|
||||||
self.smartplug.led = leds_on
|
|
||||||
self._state = None
|
self._state = None
|
||||||
self._available = True
|
self._available = True
|
||||||
# Set up emeter cache
|
# Set up emeter cache
|
||||||
@ -94,6 +93,10 @@ class SmartPlugSwitch(SwitchDevice):
|
|||||||
self._state = self.smartplug.state == \
|
self._state = self.smartplug.state == \
|
||||||
self.smartplug.SWITCH_STATE_ON
|
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
|
# Pull the name from the device if a name was not specified
|
||||||
if self._name == DEFAULT_NAME:
|
if self._name == DEFAULT_NAME:
|
||||||
self._name = self.smartplug.alias
|
self._name = self.smartplug.alias
|
||||||
|
Loading…
x
Reference in New Issue
Block a user