Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance optimization of TP-Link switch #11416

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions homeassistant/components/switch/tplink.py
Expand Up @@ -24,12 +24,11 @@
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,
})


Expand All @@ -51,7 +50,8 @@ def __init__(self, smartplug, name, leds_on):
"""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
Expand Down Expand Up @@ -96,8 +96,6 @@ def update(self):
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()

Expand Down