mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Bring back delayed zwave value update behavior (#2674)
This commit is contained in:
parent
b35c44ce04
commit
e0cbb92c05
@ -8,6 +8,7 @@ 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
|
||||||
@ -108,7 +109,22 @@ class ZwaveDimmer(zwave.ZWaveDeviceEntity, Light):
|
|||||||
"""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 or \
|
if self._value.value_id == value.value_id or \
|
||||||
self._value.node == value.node:
|
self._value.node == value.node:
|
||||||
|
|
||||||
|
if self._refreshing:
|
||||||
|
self._refreshing = False
|
||||||
self.update_properties()
|
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
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user