Added zwave lock state from alarm type workaround (#18996)
Thank you 👍
* added zwave lock state from alarm type workaround
* fixed test indents
* more linting fixes
* one more linting fix
* simplified logic
* fixed lint new lines
* fixed merge conflict issue
* fixed definition of _alarm_type_workaround in zwave lock
This commit is contained in:
parent
aacf7ba9aa
commit
fb5b5223fb
2 changed files with 54 additions and 1 deletions
|
@ -32,6 +32,7 @@ POLYCONTROL_DANALOCK_V2_BTZE_LOCK = (POLYCONTROL, DANALOCK_V2_BTZE)
|
||||||
WORKAROUND_V2BTZE = 1
|
WORKAROUND_V2BTZE = 1
|
||||||
WORKAROUND_DEVICE_STATE = 2
|
WORKAROUND_DEVICE_STATE = 2
|
||||||
WORKAROUND_TRACK_MESSAGE = 4
|
WORKAROUND_TRACK_MESSAGE = 4
|
||||||
|
WORKAROUND_ALARM_TYPE = 8
|
||||||
|
|
||||||
DEVICE_MAPPINGS = {
|
DEVICE_MAPPINGS = {
|
||||||
POLYCONTROL_DANALOCK_V2_BTZE_LOCK: WORKAROUND_V2BTZE,
|
POLYCONTROL_DANALOCK_V2_BTZE_LOCK: WORKAROUND_V2BTZE,
|
||||||
|
@ -43,7 +44,7 @@ DEVICE_MAPPINGS = {
|
||||||
(0x0129, 0xAA00): WORKAROUND_DEVICE_STATE,
|
(0x0129, 0xAA00): WORKAROUND_DEVICE_STATE,
|
||||||
(0x0129, 0x0000): WORKAROUND_DEVICE_STATE,
|
(0x0129, 0x0000): WORKAROUND_DEVICE_STATE,
|
||||||
# Yale YRD220 (as reported by adrum in PR #17386)
|
# Yale YRD220 (as reported by adrum in PR #17386)
|
||||||
(0x0109, 0x0000): WORKAROUND_DEVICE_STATE,
|
(0x0109, 0x0000): WORKAROUND_DEVICE_STATE | WORKAROUND_ALARM_TYPE,
|
||||||
# Schlage BE469
|
# Schlage BE469
|
||||||
(0x003B, 0x5044): WORKAROUND_DEVICE_STATE | WORKAROUND_TRACK_MESSAGE,
|
(0x003B, 0x5044): WORKAROUND_DEVICE_STATE | WORKAROUND_TRACK_MESSAGE,
|
||||||
# Schlage FE599NX
|
# Schlage FE599NX
|
||||||
|
@ -237,6 +238,7 @@ class ZwaveLock(zwave.ZWaveDeviceEntity, LockDevice):
|
||||||
self._state_workaround = False
|
self._state_workaround = False
|
||||||
self._track_message_workaround = False
|
self._track_message_workaround = False
|
||||||
self._previous_message = None
|
self._previous_message = None
|
||||||
|
self._alarm_type_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
|
||||||
|
@ -257,6 +259,10 @@ class ZwaveLock(zwave.ZWaveDeviceEntity, LockDevice):
|
||||||
if workaround & WORKAROUND_TRACK_MESSAGE:
|
if workaround & WORKAROUND_TRACK_MESSAGE:
|
||||||
self._track_message_workaround = True
|
self._track_message_workaround = True
|
||||||
_LOGGER.debug("Message tracking workaround enabled")
|
_LOGGER.debug("Message tracking workaround enabled")
|
||||||
|
if workaround & WORKAROUND_ALARM_TYPE:
|
||||||
|
self._alarm_type_workaround = True
|
||||||
|
_LOGGER.debug(
|
||||||
|
"Alarm Type device state workaround enabled")
|
||||||
self.update_properties()
|
self.update_properties()
|
||||||
|
|
||||||
def update_properties(self):
|
def update_properties(self):
|
||||||
|
@ -311,6 +317,12 @@ class ZwaveLock(zwave.ZWaveDeviceEntity, LockDevice):
|
||||||
|
|
||||||
if not alarm_type:
|
if not alarm_type:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self._alarm_type_workaround:
|
||||||
|
self._state = LOCK_STATUS.get(str(alarm_type))
|
||||||
|
_LOGGER.debug("workaround: lock state set to %s -- alarm type: %s",
|
||||||
|
self._state, str(alarm_type))
|
||||||
|
|
||||||
if alarm_type == 21:
|
if alarm_type == 21:
|
||||||
self._lock_status = '{}{}'.format(
|
self._lock_status = '{}{}'.format(
|
||||||
LOCK_ALARM_TYPE.get(str(alarm_type)),
|
LOCK_ALARM_TYPE.get(str(alarm_type)),
|
||||||
|
|
|
@ -143,6 +143,47 @@ def test_v2btze_value_changed(mock_openzwave):
|
||||||
assert device.is_locked
|
assert device.is_locked
|
||||||
|
|
||||||
|
|
||||||
|
def test_alarm_type_workaround(mock_openzwave):
|
||||||
|
"""Test value changed for Z-Wave lock using alarm type."""
|
||||||
|
node = MockNode(manufacturer_id='0109', product_id='0000')
|
||||||
|
values = MockEntityValues(
|
||||||
|
primary=MockValue(data=True, node=node),
|
||||||
|
access_control=None,
|
||||||
|
alarm_type=MockValue(data=16, node=node),
|
||||||
|
alarm_level=None,
|
||||||
|
)
|
||||||
|
device = zwave.get_device(node=node, values=values)
|
||||||
|
assert not device.is_locked
|
||||||
|
|
||||||
|
values.alarm_type.data = 18
|
||||||
|
value_changed(values.alarm_type)
|
||||||
|
assert device.is_locked
|
||||||
|
|
||||||
|
values.alarm_type.data = 19
|
||||||
|
value_changed(values.alarm_type)
|
||||||
|
assert not device.is_locked
|
||||||
|
|
||||||
|
values.alarm_type.data = 21
|
||||||
|
value_changed(values.alarm_type)
|
||||||
|
assert device.is_locked
|
||||||
|
|
||||||
|
values.alarm_type.data = 22
|
||||||
|
value_changed(values.alarm_type)
|
||||||
|
assert not device.is_locked
|
||||||
|
|
||||||
|
values.alarm_type.data = 24
|
||||||
|
value_changed(values.alarm_type)
|
||||||
|
assert device.is_locked
|
||||||
|
|
||||||
|
values.alarm_type.data = 25
|
||||||
|
value_changed(values.alarm_type)
|
||||||
|
assert not device.is_locked
|
||||||
|
|
||||||
|
values.alarm_type.data = 27
|
||||||
|
value_changed(values.alarm_type)
|
||||||
|
assert device.is_locked
|
||||||
|
|
||||||
|
|
||||||
def test_lock_access_control(mock_openzwave):
|
def test_lock_access_control(mock_openzwave):
|
||||||
"""Test access control for Z-Wave lock."""
|
"""Test access control for Z-Wave lock."""
|
||||||
node = MockNode()
|
node = MockNode()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue