From 96b191c7a6d30df3b2f8a301491ced61c84a49e2 Mon Sep 17 00:00:00 2001 From: Sebastian Muszynski Date: Mon, 23 Oct 2017 11:15:49 +0200 Subject: [PATCH] Code clean-up. --- homeassistant/components/switch/xiaomi_miio.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/switch/xiaomi_miio.py b/homeassistant/components/switch/xiaomi_miio.py index a077f87affa4..5fc5e4babaf3 100644 --- a/homeassistant/components/switch/xiaomi_miio.py +++ b/homeassistant/components/switch/xiaomi_miio.py @@ -18,7 +18,7 @@ from homeassistant.exceptions import PlatformNotReady _LOGGER = logging.getLogger(__name__) DEFAULT_NAME = 'Xiaomi Miio Switch' -PLATFORM = 'xiaomi_miio' + PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ vol.Required(CONF_HOST): cv.string, vol.Required(CONF_TOKEN): vol.All(cv.string, vol.Length(min=32, max=32)), @@ -154,20 +154,16 @@ class XiaomiPlugGenericSwitch(SwitchDevice): @asyncio.coroutine def async_turn_on(self, **kwargs): """Turn the plug on.""" - result = yield from self._try_command( - "Turning the plug on failed.", self._plug.on) - - if result: + if (yield from self._try_command("Turning the plug on failed.", + self._plug.on)): self._state = True self._skip_update = True @asyncio.coroutine def async_turn_off(self, **kwargs): """Turn the plug off.""" - result = yield from self._try_command( - "Turning the plug off failed.", self._plug.off) - - if result: + if (yield from self._try_command("Turning the plug off failed.", + self._plug.off)): self._state = False self._skip_update = True