Performance optimization of TP-Link switch (#11416)

This commit is contained in:
Anders Melchiorsen 2018-01-02 19:31:33 +01:00 committed by GitHub
parent 909f613324
commit feb70b47df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,12 +24,11 @@ ATTR_CURRENT_A = 'current_a'
CONF_LEDS = 'enable_leds'
DEFAULT_NAME = 'TP-Link Switch'
DEFAULT_LEDS = True
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_LEDS, default=DEFAULT_LEDS): cv.boolean,
vol.Optional(CONF_LEDS): cv.boolean,
})
@ -51,7 +50,8 @@ class SmartPlugSwitch(SwitchDevice):
"""Initialize the switch."""
self.smartplug = smartplug
self._name = name
self._leds_on = leds_on
if leds_on is not None:
self.smartplug.led = leds_on
self._state = None
self._available = True
# Set up emeter cache
@ -96,8 +96,6 @@ class SmartPlugSwitch(SwitchDevice):
if self._name is None:
self._name = self.smartplug.alias
self.smartplug.led = self._leds_on
if self.smartplug.has_emeter:
emeter_readings = self.smartplug.get_emeter_realtime()