hass-core/homeassistant/components/lock
Andrew Hayworth 65bd308491 Set lock status correctly for Schlage BE469 Z-Wave locks (#18737)
* Set lock status correctly for Schlage BE469 Z-Wave locks

PR #17386 attempted to improve the state of z-wave lock tracking for
some problematic models. However, it operated under a flawed
assumptions. Namely, that we can always trust `self.values` to have
fresh data, and that the Schlage BE469 sends alarm reports after every
lock event. We can't trust `self.values`, and the Schlage is very
broken. :)

When we receive a notification from the driver about a state change,
we call `update_properties` - but we can (and do!) have _stale_
properties left over from previous updates. #17386 really works best
if you start from a clean slate each time. However, `update_properties`
is called on every value update, and we don't get a reason why.
Moreover, values that weren't just refreshed are not removed. So blindly
looking at something like `self.values.access_control` when deciding to
apply a workaround is not going to always be correct - it may or may not
be, depending on what happened in the past.

For the sad case of the BE469, here are the Z-Wave events that happen
under various circumstances:

RF Lock / Unlock:
- Send: door lock command set
- Receive: door lock report
- Send: door lock command get
- Receive: door lock report

Manual lock / Unlock:
- Receive: alarm
- Send: door lock command get
- Receive: door lock report

Keypad lock / Unlock:
- Receive: alarm
- Send: door lock command get
- Receive: door lock report

Thus, this PR introduces yet another work around - we track the current
and last z-wave command that the driver saw, and make assumptions based
on the sequence of events. This seems to be the most reliable way to go
- simply asking the driver to refresh various states doesn't clear out
alarms the way you would expect; this model doesn't support the access
control logging commands; and trying to manually clear out alarm state
when calling RF lock/unlock was tricky.

The lock state, when the z-wave network restarts, may look out of sync
for a few minutes. However, after the full network restart is complete,
everything looks good in my testing.

* Fix linter
2018-12-17 10:46:30 +01:00
..
__init__.py Move more MQTT platforms to config entries (#18180) 2018-11-06 16:09:46 +01:00
abode.py add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
august.py Set available property (#17706) 2018-10-23 14:09:08 +02:00
bmw_connected_drive.py Async syntax 5, light & lock & remote & scene & telegram & helpers (#17019) 2018-10-01 08:56:50 +02:00
demo.py add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
homematic.py add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
isy994.py add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
kiwi.py add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
lockitron.py add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
mqtt.py Restore states through a JSON store instead of recorder (#17270) 2018-11-28 13:16:43 +01:00
nello.py Update pynello to 2.0.2 (#18402) 2018-11-12 09:54:08 -05:00
nuki.py Async syntax 5, light & lock & remote & scene & telegram & helpers (#17019) 2018-10-01 08:56:50 +02:00
services.yaml Update services.yaml files (#10229) 2017-10-30 21:39:12 +01:00
sesame.py add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
template.py Add context to scripts run by template entities (#17329) 2018-10-15 11:38:49 +02:00
tesla.py add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
vera.py add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
verisure.py Allow verisure locks to be configured with a default code (#18873) 2018-12-03 07:25:54 +01:00
volvooncall.py Update of volvooncall component (#18702) 2018-11-30 19:07:42 +01:00
wink.py Async syntax 5, light & lock & remote & scene & telegram & helpers (#17019) 2018-10-01 08:56:50 +02:00
xiaomi_aqara.py add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
zwave.py Set lock status correctly for Schlage BE469 Z-Wave locks (#18737) 2018-12-17 10:46:30 +01:00