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.
This commit is contained in:
John Arild Berentsen 2016-07-26 08:26:40 +02:00 committed by GitHub
parent 0eac187d97
commit b4990d61f9
5 changed files with 10 additions and 24 deletions

View File

@ -94,7 +94,8 @@ class ZWaveBinarySensor(BinarySensorDevice, zwave.ZWaveDeviceEntity, Entity):
def value_changed(self, value): def value_changed(self, value):
"""Called when a value has changed on the network.""" """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() self.update_ha_state()

View File

@ -44,7 +44,6 @@ class ZwaveGarageDoor(zwave.ZWaveDeviceEntity, GarageDoorDevice):
from openzwave.network import ZWaveNetwork from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher from pydispatch import dispatcher
ZWaveDeviceEntity.__init__(self, value, DOMAIN) ZWaveDeviceEntity.__init__(self, value, DOMAIN)
self._node = value.node
self._state = value.data self._state = value.data
dispatcher.connect( dispatcher.connect(
self.value_changed, ZWaveNetwork.SIGNAL_VALUE_CHANGED) 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.""" """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:
self._state = value.data self._state = value.data
self.update_ha_state(True) self.update_ha_state()
_LOGGER.debug("Value changed on network %s", value) _LOGGER.debug("Value changed on network %s", value)
@property @property

View File

@ -8,7 +8,6 @@ import logging
# Because we do not compile openzwave on CI # Because we do not compile openzwave on CI
# pylint: disable=import-error # pylint: disable=import-error
from threading import Timer
from homeassistant.components.light import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, \ from homeassistant.components.light import ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, \
ATTR_RGB_COLOR, DOMAIN, Light ATTR_RGB_COLOR, DOMAIN, Light
from homeassistant.components import zwave from homeassistant.components import zwave
@ -107,25 +106,10 @@ class ZwaveDimmer(zwave.ZWaveDeviceEntity, Light):
def _value_changed(self, value): def _value_changed(self, value):
"""Called when a value has changed on the network.""" """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 \
return self._value.node == value.node:
if self._refreshing:
self._refreshing = False
self.update_properties() self.update_properties()
else: self.update_ha_state()
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()
@property @property
def brightness(self): def brightness(self):

View File

@ -46,7 +46,8 @@ class ZwaveLock(zwave.ZWaveDeviceEntity, LockDevice):
def _value_changed(self, value): def _value_changed(self, value):
"""Called when a value has changed on the network.""" """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._state = value.data
self.update_ha_state() self.update_ha_state()

View File

@ -96,7 +96,8 @@ class ZWaveSensor(zwave.ZWaveDeviceEntity, Entity):
def value_changed(self, value): def value_changed(self, value):
"""Called when a value has changed on the network.""" """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() self.update_ha_state()