jbergler / hass-ttlock

Home Assistant integration for TTLock locks
54 stars 12 forks source link

Automatic relocking isn't reported to home assistant #21

Closed jbergler closed 1 year ago

jbergler commented 1 year ago

This morning i have got some updates. It looks like it's not picking up the auto-relock

Screenshot 2023-04-21 at 09 13 10

Originally posted by @stevearmitage in https://github.com/jbergler/hass-ttlock/issues/1#issuecomment-1517119820


The crux of this issue is that the locks don't send a lock event when they re-lock after the configured period of time.

I emailed the TTLock developers a little about this and it seems the only solution is for home assistant to assume the lock re-locked if it was configured to do so.

The alternative might be to poll the lock for status after the configured period, but that seems wasteful of battery and unlikely to tell us anything useful.

jbergler commented 1 year ago

@stevearmitage v0.4.3 has a first attempt at assuming the state the lock is in when the lock has autolock and/or passage mode configured but doesn't report the events. I'm sure there's edge cases, so I'll leave this open for a bit, please let me know how you get on.

jbergler commented 1 year ago

Making a note for myself later

2023-04-23 22:08:23.562 DEBUG (MainThread) [custom_components.ttlock.coordinator] Lock ttlock-7252408 received id=7252408 mac='16:72:4C:CC:01:C4' battery_level=92 server_ts=datetime.datetime(2023, 4, 23, 10, 8, 23, 226000, tzinfo=datetime.timezone.utc) lock_ts=datetime.datetime(2023, 4, 23, 10, 8, 17, tzinfo=datetime.timezone.utc) event=Event(EventDescription(action=<Action.unlock: 3>, description='unlock by IC card')) user='Jonas' success=True
2023-04-23 22:08:23.562 DEBUG (MainThread) [custom_components.ttlock.coordinator] Auto-lock is disabled

Although

"passage_mode_config": {enabled=<OnOff.on: 1>, start_minute=420, end_minute=1200, all_day=<OnOff.off: 2>, week_days=[1, 2, 3, 4, 5, 6, 7], auto_unlock=<OnOff.off: 2>}

There's probably a timezone thing going on

2023-04-23 22:08:23.561 -> 1682244497000
ronluna commented 1 year ago

I'm currently on the same boat. The lock automatically autolocks itself after a couples of seconds without reporting anything to the gateway and leaving HA with the incorrect lock status report. Wondering if there is a way to go around this?