Update Insight parameters using the subscription data. (#6782)

* Update Insight parameters using the subscription dta.

* Minor refactor.

* Tidy.
This commit is contained in:
Greg Dowling 2017-03-27 11:43:43 +01:00 committed by Pascal Vizeli
parent f242ad26ca
commit c53de19246
3 changed files with 9 additions and 10 deletions

View File

@ -61,16 +61,14 @@ class WemoSwitch(SwitchDevice):
wemo.SUBSCRIPTION_REGISTRY.register(self.wemo) wemo.SUBSCRIPTION_REGISTRY.register(self.wemo)
wemo.SUBSCRIPTION_REGISTRY.on(self.wemo, None, self._update_callback) 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.""" """Called by the Wemo device callback to update state."""
_LOGGER.info( _LOGGER.info(
'Subscription update for %s', 'Subscription update for %s',
_device) _device)
if self._model_name == 'CoffeeMaker': updated = self.wemo.subscription_update(_type, _params)
self.wemo.subscription_callback(_params) self._update(force_update=(not updated))
self._update(force_update=False)
else:
self.update()
if not hasattr(self, 'hass'): if not hasattr(self, 'hass'):
return return
self.schedule_update_ha_state() self.schedule_update_ha_state()
@ -219,5 +217,6 @@ class WemoSwitch(SwitchDevice):
self.maker_params = self.wemo.maker_params self.maker_params = self.wemo.maker_params
elif self._model_name == 'CoffeeMaker': elif self._model_name == 'CoffeeMaker':
self.coffeemaker_mode = self.wemo.mode self.coffeemaker_mode = self.wemo.mode
except AttributeError: except AttributeError as err:
_LOGGER.warning('Could not update status for %s', self.name) _LOGGER.warning('Could not update status for %s (%s)',
self.name, err)

View File

@ -14,7 +14,7 @@ from homeassistant.helpers import config_validation as cv
from homeassistant.const import EVENT_HOMEASSISTANT_STOP from homeassistant.const import EVENT_HOMEASSISTANT_STOP
REQUIREMENTS = ['pywemo==0.4.13'] REQUIREMENTS = ['pywemo==0.4.15']
DOMAIN = 'wemo' DOMAIN = 'wemo'

View File

@ -647,7 +647,7 @@ pyvera==0.2.24
pywebpush==0.6.1 pywebpush==0.6.1
# homeassistant.components.wemo # homeassistant.components.wemo
pywemo==0.4.13 pywemo==0.4.15
# homeassistant.components.zabbix # homeassistant.components.zabbix
pyzabbix==0.7.4 pyzabbix==0.7.4