From 4feef3dd0d12b392041c3f12d0b1c5b8da9e1a82 Mon Sep 17 00:00:00 2001 From: pavoni Date: Sun, 27 Dec 2015 23:09:39 +0000 Subject: [PATCH] Simplify update state call, shutdown properly. --- homeassistant/components/switch/wemo.py | 8 ++++++-- requirements_all.txt | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/switch/wemo.py b/homeassistant/components/switch/wemo.py index 1861b42f450..c15ef4612f0 100644 --- a/homeassistant/components/switch/wemo.py +++ b/homeassistant/components/switch/wemo.py @@ -27,6 +27,11 @@ def setup_platform(hass, config, add_devices_callback, discovery_info=None): if _WEMO_SUBSCRIPTION_REGISTRY is None: _WEMO_SUBSCRIPTION_REGISTRY = pywemo.SubscriptionRegistry() _WEMO_SUBSCRIPTION_REGISTRY.start() + def stop_wemo(event): + """ Shutdown Wemo subscriptions and subscription thread on exit""" + _WEMO_SUBSCRIPTION_REGISTRY.stop() + + hass.bus.listen_once(hass.EVENT_HOMEASSISTANT_STOP, stop_wemo) if discovery_info is not None: location = discovery_info[2] @@ -63,8 +68,7 @@ class WemoSwitch(SwitchDevice): _LOGGER.info( 'Subscription update for %s, sevice=%s params=%s', self.name, _device, _params) - self.update() - self.update_ha_state() + self.update_ha_state(True) @property def should_poll(self): diff --git a/requirements_all.txt b/requirements_all.txt index 2375721fa7d..8494573de42 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -174,7 +174,7 @@ hikvision==0.4 orvibo==1.1.0 # homeassistant.components.switch.wemo -pywemo==0.3.3 +pywemo==0.3.4 # homeassistant.components.thermostat.heatmiser heatmiserV3==0.9.1