Bring back delayed zwave value update behavior (#2674)

pull/2670/merge
Jesse Newland 2016-07-31 02:09:01 -05:00 committed by John Arild Berentsen
parent b35c44ce04
commit e0cbb92c05
1 changed files with 17 additions and 1 deletions

View File

@ -8,6 +8,7 @@ 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
@ -108,7 +109,22 @@ class ZwaveDimmer(zwave.ZWaveDeviceEntity, Light):
"""Called when a value has changed on the network."""
if self._value.value_id == value.value_id or \
self._value.node == value.node:
self.update_properties()
if self._refreshing:
self._refreshing = False
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()
@property