From bbad15f85307c5e5a9b4f630602a62e0b04a1f7f Mon Sep 17 00:00:00 2001 From: Greg Dowling Date: Tue, 18 Apr 2017 17:11:08 +0100 Subject: [PATCH] Add subscription update for Wemo switches, fix bug in Insight switches, fix wemo motion bug, fix wemo discovery (#7135) * Fix wemo discovery. * Bump wemo version, add subscription_update for basic switch, fix bug with turning insight switches off. * Fix missed callback change for wemo motion. * Regress netdisco changes. --- homeassistant/components/binary_sensor/wemo.py | 18 ++++++++++++------ homeassistant/components/wemo.py | 2 +- requirements_all.txt | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/binary_sensor/wemo.py b/homeassistant/components/binary_sensor/wemo.py index 07deea02f6e..7f44370510e 100644 --- a/homeassistant/components/binary_sensor/wemo.py +++ b/homeassistant/components/binary_sensor/wemo.py @@ -40,12 +40,14 @@ class WemoBinarySensor(BinarySensorDevice): wemo.SUBSCRIPTION_REGISTRY.register(self.wemo) wemo.SUBSCRIPTION_REGISTRY.on(self.wemo, None, self._update_callback) - def _update_callback(self, _device, _params): - """Called by the wemo device callback to update state.""" + def _update_callback(self, _device, _type, _params): + """Called by the Wemo device callback to update state.""" _LOGGER.info( 'Subscription update for %s', _device) - 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() @@ -72,7 +74,11 @@ class WemoBinarySensor(BinarySensorDevice): def update(self): """Update WeMo state.""" + self._update(force_update=True) + + def _update(self, force_update=True): try: - self._state = self.wemo.get_state(True) - except AttributeError: - _LOGGER.warning('Could not update status for %s', self.name) + self._state = self.wemo.get_state(force_update) + 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 20c9f6eeca2..d9fa0bc7f56 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.17'] +REQUIREMENTS = ['pywemo==0.4.18'] DOMAIN = 'wemo' diff --git a/requirements_all.txt b/requirements_all.txt index 8a6f550d1f9..7ae864fd84e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -672,7 +672,7 @@ pyvera==0.2.26 pywebpush==0.6.1 # homeassistant.components.wemo -pywemo==0.4.17 +pywemo==0.4.18 # homeassistant.components.zabbix pyzabbix==0.7.4