mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Add workaround to use notification state for zwave lock state (#17386)
* Add workaround to use notification state for zwave lock state There are several zwave lock models out there which do not seem to update the lock state on non-rf events (see #11934 #14632 #14534 for examples) including kwikset smartkey zwave plus locks (which I own). In these cases it seems that the notifications for non-rf events the access_control value is updated but not the primary value for the lock state, which is what is used to set the is_locked property. To properly have the lock state accurate for all types of notifications on these models we need to use the access_control field. This commit adds a workaround for the 4 models reported to exhibit this behavior so that home-assistant will reliably set the lock state for all device notifications. * Add YRD220 as per adrum to workaround list * Inline constants
This commit is contained in:
parent
2bf2214d51
commit
087bffeaae
@ -28,9 +28,22 @@ POLYCONTROL = 0x10E
|
|||||||
DANALOCK_V2_BTZE = 0x2
|
DANALOCK_V2_BTZE = 0x2
|
||||||
POLYCONTROL_DANALOCK_V2_BTZE_LOCK = (POLYCONTROL, DANALOCK_V2_BTZE)
|
POLYCONTROL_DANALOCK_V2_BTZE_LOCK = (POLYCONTROL, DANALOCK_V2_BTZE)
|
||||||
WORKAROUND_V2BTZE = 'v2btze'
|
WORKAROUND_V2BTZE = 'v2btze'
|
||||||
|
WORKAROUND_DEVICE_STATE = 'state'
|
||||||
|
|
||||||
DEVICE_MAPPINGS = {
|
DEVICE_MAPPINGS = {
|
||||||
POLYCONTROL_DANALOCK_V2_BTZE_LOCK: WORKAROUND_V2BTZE
|
POLYCONTROL_DANALOCK_V2_BTZE_LOCK: WORKAROUND_V2BTZE,
|
||||||
|
# Kwikset 914TRL ZW500
|
||||||
|
(0x0090, 0x440): WORKAROUND_DEVICE_STATE,
|
||||||
|
# Yale YRD210
|
||||||
|
(0x0129, 0x0209): WORKAROUND_DEVICE_STATE,
|
||||||
|
(0x0129, 0xAA00): WORKAROUND_DEVICE_STATE,
|
||||||
|
(0x0129, 0x0000): WORKAROUND_DEVICE_STATE,
|
||||||
|
# Yale YRD220 (as reported by adrum in PR #17386)
|
||||||
|
(0x0109, 0x0000): WORKAROUND_DEVICE_STATE,
|
||||||
|
# Schlage BE469
|
||||||
|
(0x003B, 0x5044): WORKAROUND_DEVICE_STATE,
|
||||||
|
# Schlage FE599NX
|
||||||
|
(0x003B, 0x504C): WORKAROUND_DEVICE_STATE,
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK_NOTIFICATION = {
|
LOCK_NOTIFICATION = {
|
||||||
@ -204,6 +217,7 @@ class ZwaveLock(zwave.ZWaveDeviceEntity, LockDevice):
|
|||||||
self._notification = None
|
self._notification = None
|
||||||
self._lock_status = None
|
self._lock_status = None
|
||||||
self._v2btze = None
|
self._v2btze = None
|
||||||
|
self._state_workaround = False
|
||||||
|
|
||||||
# Enable appropriate workaround flags for our device
|
# Enable appropriate workaround flags for our device
|
||||||
# Make sure that we have values for the key before converting to int
|
# Make sure that we have values for the key before converting to int
|
||||||
@ -216,6 +230,11 @@ class ZwaveLock(zwave.ZWaveDeviceEntity, LockDevice):
|
|||||||
self._v2btze = 1
|
self._v2btze = 1
|
||||||
_LOGGER.debug("Polycontrol Danalock v2 BTZE "
|
_LOGGER.debug("Polycontrol Danalock v2 BTZE "
|
||||||
"workaround enabled")
|
"workaround enabled")
|
||||||
|
if DEVICE_MAPPINGS[specific_sensor_key] == \
|
||||||
|
WORKAROUND_DEVICE_STATE:
|
||||||
|
self._state_workaround = True
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Notification device state workaround enabled")
|
||||||
self.update_properties()
|
self.update_properties()
|
||||||
|
|
||||||
def update_properties(self):
|
def update_properties(self):
|
||||||
@ -225,7 +244,8 @@ class ZwaveLock(zwave.ZWaveDeviceEntity, LockDevice):
|
|||||||
if self.values.access_control:
|
if self.values.access_control:
|
||||||
notification_data = self.values.access_control.data
|
notification_data = self.values.access_control.data
|
||||||
self._notification = LOCK_NOTIFICATION.get(str(notification_data))
|
self._notification = LOCK_NOTIFICATION.get(str(notification_data))
|
||||||
|
if self._state_workaround:
|
||||||
|
self._state = LOCK_STATUS.get(str(notification_data))
|
||||||
if self._v2btze:
|
if self._v2btze:
|
||||||
if self.values.v2btze_advanced and \
|
if self.values.v2btze_advanced and \
|
||||||
self.values.v2btze_advanced.data == CONFIG_ADVANCED:
|
self.values.v2btze_advanced.data == CONFIG_ADVANCED:
|
||||||
|
@ -63,6 +63,22 @@ def test_lock_value_changed(mock_openzwave):
|
|||||||
assert device.is_locked
|
assert device.is_locked
|
||||||
|
|
||||||
|
|
||||||
|
def test_lock_value_changed_workaround(mock_openzwave):
|
||||||
|
"""Test value changed for Z-Wave lock using notification state."""
|
||||||
|
node = MockNode(manufacturer_id='0090', product_id='0440')
|
||||||
|
values = MockEntityValues(
|
||||||
|
primary=MockValue(data=True, node=node),
|
||||||
|
access_control=MockValue(data=1, node=node),
|
||||||
|
alarm_type=None,
|
||||||
|
alarm_level=None,
|
||||||
|
)
|
||||||
|
device = zwave.get_device(node=node, values=values)
|
||||||
|
assert device.is_locked
|
||||||
|
values.access_control.data = 2
|
||||||
|
value_changed(values.access_control)
|
||||||
|
assert not device.is_locked
|
||||||
|
|
||||||
|
|
||||||
def test_v2btze_value_changed(mock_openzwave):
|
def test_v2btze_value_changed(mock_openzwave):
|
||||||
"""Test value changed for v2btze Z-Wave lock."""
|
"""Test value changed for v2btze Z-Wave lock."""
|
||||||
node = MockNode(manufacturer_id='010e', product_id='0002')
|
node = MockNode(manufacturer_id='010e', product_id='0002')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user