From b4990d61f9f87a02f65b3296ffcc0c2f6081f0ff Mon Sep 17 00:00:00 2001 From: John Arild Berentsen Date: Tue, 26 Jul 2016 08:26:40 +0200 Subject: [PATCH] Make sure zwave values are updated regardles of manual or frontend update, (#2595) * Make sure values are updated regardles of manual or frontend update, * Devices with set_switch command was not happy with fast updating. * Binary triggersensors command was not happy with refreshed updating. --- .../components/binary_sensor/zwave.py | 3 ++- homeassistant/components/garage_door/zwave.py | 3 +-- homeassistant/components/light/zwave.py | 22 +++---------------- homeassistant/components/lock/zwave.py | 3 ++- homeassistant/components/sensor/zwave.py | 3 ++- 5 files changed, 10 insertions(+), 24 deletions(-) diff --git a/homeassistant/components/binary_sensor/zwave.py b/homeassistant/components/binary_sensor/zwave.py index 0f2a13263aa..1b47b98fe9f 100644 --- a/homeassistant/components/binary_sensor/zwave.py +++ b/homeassistant/components/binary_sensor/zwave.py @@ -94,7 +94,8 @@ class ZWaveBinarySensor(BinarySensorDevice, zwave.ZWaveDeviceEntity, Entity): def value_changed(self, value): """Called when a value has changed on the network.""" - if self._value.value_id == value.value_id: + if self._value.value_id == value.value_id or \ + self._value.node == value.node: self.update_ha_state() diff --git a/homeassistant/components/garage_door/zwave.py b/homeassistant/components/garage_door/zwave.py index b527fc0052c..e8aacf0b6ad 100644 --- a/homeassistant/components/garage_door/zwave.py +++ b/homeassistant/components/garage_door/zwave.py @@ -44,7 +44,6 @@ class ZwaveGarageDoor(zwave.ZWaveDeviceEntity, GarageDoorDevice): from openzwave.network import ZWaveNetwork from pydispatch import dispatcher ZWaveDeviceEntity.__init__(self, value, DOMAIN) - self._node = value.node self._state = value.data dispatcher.connect( self.value_changed, ZWaveNetwork.SIGNAL_VALUE_CHANGED) @@ -53,7 +52,7 @@ class ZwaveGarageDoor(zwave.ZWaveDeviceEntity, GarageDoorDevice): """Called when a value has changed on the network.""" if self._value.value_id == value.value_id: self._state = value.data - self.update_ha_state(True) + self.update_ha_state() _LOGGER.debug("Value changed on network %s", value) @property diff --git a/homeassistant/components/light/zwave.py b/homeassistant/components/light/zwave.py index 2aed8d54a8c..ab41381f5e7 100644 --- a/homeassistant/components/light/zwave.py +++ b/homeassistant/components/light/zwave.py @@ -8,7 +8,6 @@ import logging # Because we do not compile openzwave on CI # pylint: disable=import-error -from threading import Timer from homeassistant.components.light import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, \ ATTR_RGB_COLOR, DOMAIN, Light from homeassistant.components import zwave @@ -107,25 +106,10 @@ class ZwaveDimmer(zwave.ZWaveDeviceEntity, Light): def _value_changed(self, value): """Called when a value has changed on the network.""" - if self._value.value_id != value.value_id: - return - - if self._refreshing: - self._refreshing = False + if self._value.value_id == value.value_id or \ + self._value.node == value.node: self.update_properties() - else: - def _refresh_value(): - """Used timer callback for delayed value refresh.""" - self._refreshing = True - self._value.refresh() - - if self._timer is not None and self._timer.isAlive(): - self._timer.cancel() - - self._timer = Timer(2, _refresh_value) - self._timer.start() - - self.update_ha_state() + self.update_ha_state() @property def brightness(self): diff --git a/homeassistant/components/lock/zwave.py b/homeassistant/components/lock/zwave.py index 9a3b24deb8a..7416d5c439b 100644 --- a/homeassistant/components/lock/zwave.py +++ b/homeassistant/components/lock/zwave.py @@ -46,7 +46,8 @@ class ZwaveLock(zwave.ZWaveDeviceEntity, LockDevice): def _value_changed(self, value): """Called when a value has changed on the network.""" - if self._value.value_id == value.value_id: + if self._value.value_id == value.value_id or \ + self._value.node == value.node: self._state = value.data self.update_ha_state() diff --git a/homeassistant/components/sensor/zwave.py b/homeassistant/components/sensor/zwave.py index 8748ef86572..023ddf4db82 100644 --- a/homeassistant/components/sensor/zwave.py +++ b/homeassistant/components/sensor/zwave.py @@ -96,7 +96,8 @@ class ZWaveSensor(zwave.ZWaveDeviceEntity, Entity): def value_changed(self, value): """Called when a value has changed on the network.""" - if self._value.value_id == value.value_id: + if self._value.value_id == value.value_id or \ + self._value.node == value.node: self.update_ha_state()