core/tests
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
..
auth Allow checking entity permissions based on devices (#19007) 2018-12-05 11:41:00 +01:00
components Set lock status correctly for Schlage BE469 Z-Wave locks (#18737) 2018-12-17 10:46:30 +01:00
fixtures Add Entur departure information sensor (#17286) 2018-11-30 09:06:59 +01:00
helpers Allow checking entity permissions based on devices (#19007) 2018-12-05 11:41:00 +01:00
mock Add zwave.network_complete_some_dead event (#16894) 2018-09-28 19:14:57 +02:00
resources Revised package util tests 2016-01-30 14:08:32 -05:00
scripts Mqtt light refactor (#18227) 2018-11-27 14:00:05 +01:00
test_util Fix cloud const (#19052) 2018-12-06 09:20:53 +01:00
testing_config add_devices -> add_entities (#16171) 2018-08-24 16:37:30 +02:00
util Restore states through a JSON store instead of recorder (#17270) 2018-11-28 13:16:43 +01:00
__init__.py async HTTP component (#3914) 2016-10-23 23:48:01 -07:00
common.py Allow checking entity permissions based on devices (#19007) 2018-12-05 11:41:00 +01:00
conftest.py No more opt-out auth (#18854) 2018-12-02 16:32:53 +01:00
test_bootstrap.py Remove usage of "run_until_complete" (#16617) 2018-09-19 15:40:02 +02:00
test_config.py Extend partial reload to include packages (#18884) 2018-12-03 10:56:26 +01:00
test_config_entries.py Fix unloading an entry can leave states around (#17786) 2018-10-25 19:57:36 +02:00
test_core.py Add raw service data to event (#19163) 2018-12-10 13:00:35 +01:00
test_data_entry_flow.py Allow finish_flow callback to change data entry result type (#16100) 2018-08-21 10:48:24 -07:00
test_loader.py Pytest tests (#17750) 2018-10-24 12:10:05 +02:00
test_main.py Hello Python 3.5 (#12610) 2018-02-22 23:22:27 -08:00
test_requirements.py Improve package loadable (#16237) 2018-08-28 12:52:18 +02:00
test_setup.py OwnTracks Config Entry (#18759) 2018-11-28 22:20:13 +01:00