mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
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:
parent
bc9f2d21c4
commit
eaaa0442e2
@ -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):
|
||||
|
@ -10,10 +10,12 @@ SOMFY = 0x47
|
||||
# Product IDs
|
||||
PHILIO_SLIM_SENSOR = 0x0002
|
||||
PHILIO_3_IN_1_SENSOR_GEN_4 = 0x000d
|
||||
PHILIO_PAN07 = 0x0005
|
||||
|
||||
# Product Types
|
||||
FGFS101_FLOOD_SENSOR_TYPE = 0x0b00
|
||||
FGRM222_SHUTTER2 = 0x0301
|
||||
PHILIO_SWITCH = 0x0001
|
||||
PHILIO_SENSOR = 0x0002
|
||||
SOMFY_ZRTSI = 0x5a52
|
||||
|
||||
@ -21,6 +23,7 @@ SOMFY_ZRTSI = 0x5a52
|
||||
PHILIO_SLIM_SENSOR_MOTION_MTII = (PHILIO, PHILIO_SENSOR, PHILIO_SLIM_SENSOR, 0)
|
||||
PHILIO_3_IN_1_SENSOR_GEN_4_MOTION_MTII = (
|
||||
PHILIO, PHILIO_SENSOR, PHILIO_3_IN_1_SENSOR_GEN_4, 0)
|
||||
PHILIO_PAN07_MTII = (PHILIO, PHILIO_SWITCH, PHILIO_PAN07, 0)
|
||||
WENZHOU_SLIM_SENSOR_MOTION_MTII = (
|
||||
WENZHOU, PHILIO_SENSOR, PHILIO_SLIM_SENSOR, 0)
|
||||
|
||||
@ -28,6 +31,7 @@ WENZHOU_SLIM_SENSOR_MOTION_MTII = (
|
||||
WORKAROUND_NO_OFF_EVENT = 'trigger_no_off_event'
|
||||
WORKAROUND_NO_POSITION = 'workaround_no_position'
|
||||
WORKAROUND_REVERSE_OPEN_CLOSE = 'reverse_open_close'
|
||||
WORKAROUND_REFRESH_NODE_ON_UPDATE = 'refresh_node_on_update'
|
||||
WORKAROUND_IGNORE = 'workaround_ignore'
|
||||
|
||||
# List of workarounds by (manufacturer_id, product_type, product_id, index)
|
||||
@ -35,6 +39,7 @@ DEVICE_MAPPINGS_MTII = {
|
||||
PHILIO_SLIM_SENSOR_MOTION_MTII: WORKAROUND_NO_OFF_EVENT,
|
||||
PHILIO_3_IN_1_SENSOR_GEN_4_MOTION_MTII: WORKAROUND_NO_OFF_EVENT,
|
||||
WENZHOU_SLIM_SENSOR_MOTION_MTII: WORKAROUND_NO_OFF_EVENT,
|
||||
PHILIO_PAN07_MTII: WORKAROUND_REFRESH_NODE_ON_UPDATE,
|
||||
}
|
||||
|
||||
SOMFY_ZRTSI_CONTROLLER_MT = (SOMFY, SOMFY_ZRTSI)
|
||||
|
Loading…
x
Reference in New Issue
Block a user