Add a Z-wave workaround to do full refresh on update (#6403)
* Add Zwave refresh services * services file * Use dispatcher * Add zwave prefix to signal * Add a Z-wave workaround to do full refresh on update
This commit is contained in:
1 parent
bc9f2d21c4
commit
eaaa0442e2
2 files changed
+15
-2
No files matched your search
@@ -5,11 +5,12 @@ For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/switch.zwave/
|
||||
"""
|
||||
import logging
|
||||
import time
|
||||
# Because we do not compile openzwave on CI
|
||||
# pylint: disable=import-error
|
||||
from homeassistant.components.switch import DOMAIN, SwitchDevice
|
||||
from homeassistant.components import zwave
|
||||
from homeassistant.components.zwave import async_setup_platform # noqa # pylint: disable=unused-import
|
||||
from homeassistant.components.zwave import workaround, async_setup_platform # noqa # pylint: disable=unused-import
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@@ -25,11 +26,18 @@ class ZwaveSwitch(zwave.ZWaveDeviceEntity, SwitchDevice):
|
||||
def __init__(self, value):
|
||||
"""Initialize the Z-Wave switch device."""
|
||||
zwave.ZWaveDeviceEntity.__init__(self, value, DOMAIN)
|
||||
self.update_properties()
|
||||
self.refresh_on_update = (workaround.get_device_mapping(value) ==
|
||||
workaround.WORKAROUND_REFRESH_NODE_ON_UPDATE)
|
||||
self.last_update = time.perf_counter()
|
||||
self._state = self._value.data
|
||||
|
||||
def update_properties(self):
|
||||
"""Callback on data changes for node values."""
|
||||
self._state = self._value.data
|
||||
if self.refresh_on_update and \
|
||||
time.perf_counter() - self.last_update > 30:
|
||||
self.last_update = time.perf_counter()
|
||||
self._value.node.request_state()
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
||||
Reference in new issue
Block a user