From c53de19246ea10597a1a22c0f809546b2b5b2bc7 Mon Sep 17 00:00:00 2001 From: Greg Dowling Date: Mon, 27 Mar 2017 11:43:43 +0100 Subject: [PATCH] Update Insight parameters using the subscription data. (#6782) * Update Insight parameters using the subscription dta. * Minor refactor. * Tidy. --- homeassistant/components/switch/wemo.py | 15 +++++++-------- homeassistant/components/wemo.py | 2 +- requirements_all.txt | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/switch/wemo.py b/homeassistant/components/switch/wemo.py index 97c0fb3d386..e78190bf444 100644 --- a/homeassistant/components/switch/wemo.py +++ b/homeassistant/components/switch/wemo.py @@ -61,16 +61,14 @@ class WemoSwitch(SwitchDevice): wemo.SUBSCRIPTION_REGISTRY.register(self.wemo) wemo.SUBSCRIPTION_REGISTRY.on(self.wemo, None, self._update_callback) - def _update_callback(self, _device, _params): + def _update_callback(self, _device, _type, _params): """Called by the Wemo device callback to update state.""" _LOGGER.info( 'Subscription update for %s', _device) - if self._model_name == 'CoffeeMaker': - self.wemo.subscription_callback(_params) - self._update(force_update=False) - else: - self.update() + updated = self.wemo.subscription_update(_type, _params) + self._update(force_update=(not updated)) + if not hasattr(self, 'hass'): return self.schedule_update_ha_state() @@ -219,5 +217,6 @@ class WemoSwitch(SwitchDevice): self.maker_params = self.wemo.maker_params elif self._model_name == 'CoffeeMaker': self.coffeemaker_mode = self.wemo.mode - except AttributeError: - _LOGGER.warning('Could not update status for %s', self.name) + except AttributeError as err: + _LOGGER.warning('Could not update status for %s (%s)', + self.name, err) diff --git a/homeassistant/components/wemo.py b/homeassistant/components/wemo.py index c121c58470b..7cec1707211 100644 --- a/homeassistant/components/wemo.py +++ b/homeassistant/components/wemo.py @@ -14,7 +14,7 @@ from homeassistant.helpers import config_validation as cv from homeassistant.const import EVENT_HOMEASSISTANT_STOP -REQUIREMENTS = ['pywemo==0.4.13'] +REQUIREMENTS = ['pywemo==0.4.15'] DOMAIN = 'wemo' diff --git a/requirements_all.txt b/requirements_all.txt index d449f7e2d11..bb0993338f3 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -647,7 +647,7 @@ pyvera==0.2.24 pywebpush==0.6.1 # homeassistant.components.wemo -pywemo==0.4.13 +pywemo==0.4.15 # homeassistant.components.zabbix pyzabbix==0.7.4