home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.73k stars 30.85k forks source link

Loqed: Lock keeps a wrong state when calling a service to the current state #99384

Closed alexborro closed 1 year ago

alexborro commented 1 year ago

The problem

Scenario:

Action:

Current Result:

Expected Result:

The same happens if the Loqed is in Locked state and you call lock.lock service.

What version of Home Assistant Core has the issue?

core-2023.8.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Loqed

Link to integration documentation on our website

https://www.home-assistant.io/integrations/loqed

Diagnostics information

State: Unlocked. Calling lock service: 2023-08-31 09:17:32.448 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for <#####> 2023-08-31 09:17:32.449 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback received: <CIMultiDictProxy('User-Agent': 'ESP32 HTTP Client/1.0', 'Host': '', 'Accept': 'text/html', 'Accept-Encoding': 'identity', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'HASH': '92247b732d45f9634175e06d0b5e0b9c8b6748375b3001a10e60bd714c015ad9', 'TIMESTAMP': '1693466251', 'Content-Length': '153')> 2023-08-31 09:17:32.494 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback body: {"go_to_state":"NIGHT_LOCK","event_type":"GO_TO_STATE_MANUAL_LOCK_REMOTE_NIGHT_LOCK","mac_wifi":"####","mac_ble":"####","key_local_id":3} 2023-08-31 09:17:32.495 DEBUG (MainThread) [homeassistant.components.loqed.lock] {'battery_percentage': 80, 'battery_type': 'NICKEL_METAL_HYDRIDE', 'battery_type_numeric': 1, 'battery_voltage': 10.412, 'bolt_state': 'night_lock', 'bolt_state_numeric': 3, 'bridge_mac_wifi': '####', 'bridge_mac_ble': '####', 'lock_online': 1, 'webhooks_number': 1, 'ip_address': '10.0.12.120', 'up_timestamp': 1692656610, 'wifi_strength': 97, 'ble_strength': 60} 2023-08-31 09:17:39.872 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for <#####> 2023-08-31 09:17:39.872 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback received: <CIMultiDictProxy('User-Agent': 'ESP32 HTTP Client/1.0', 'Host': '', 'Accept': 'text/html', 'Accept-Encoding': 'identity', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'HASH': 'f5cb246c9024eba6af3c79512fef425c54761912feb13f31d400742cc2d53462', 'TIMESTAMP': '1693466258', 'Content-Length': '168')> 2023-08-31 09:17:39.916 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback body: {"requested_state":"NIGHT_LOCK","requested_state_numeric":3,"mac_wifi":"####","mac_ble":"####","event_type":"STATE_CHANGED_NIGHT_LOCK","key_local_id":3} 2023-08-31 09:17:39.917 DEBUG (MainThread) [homeassistant.components.loqed.lock] {'battery_percentage': 80, 'battery_type': 'NICKEL_METAL_HYDRIDE', 'battery_type_numeric': 1, 'battery_voltage': 10.412, 'bolt_state': 'night_lock', 'bolt_state_numeric': 3, 'bridge_mac_wifi': '####', 'bridge_mac_ble': '####', 'lock_online': 1, 'webhooks_number': 1, 'ip_address': '10.0.12.120', 'up_timestamp': 1692656610, 'wifi_strength': 97, 'ble_strength': 60}

State: Locked. Calling Unlock: 2023-08-31 09:18:02.658 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for <#####> 2023-08-31 09:18:02.658 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback received: <CIMultiDictProxy('User-Agent': 'ESP32 HTTP Client/1.0', 'Host': '', 'Accept': 'text/html', 'Accept-Encoding': 'identity', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'HASH': '5d05054f293a0c64a2c46f4be7a93d3eca4821476ea29b027b307fdd8b713fbb', 'TIMESTAMP': '1693466281', 'Content-Length': '146')> 2023-08-31 09:18:02.703 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback body: {"go_to_state":"DAY_LOCK","event_type":"GO_TO_STATE_MANUAL_LOCK_REMOTE_LATCH","mac_wifi":"####","mac_ble":"####","key_local_id":3} 2023-08-31 09:18:02.703 DEBUG (MainThread) [homeassistant.components.loqed.lock] {'battery_percentage': 80, 'battery_type': 'NICKEL_METAL_HYDRIDE', 'battery_type_numeric': 1, 'battery_voltage': 10.412, 'bolt_state': 'night_lock', 'bolt_state_numeric': 3, 'bridge_mac_wifi': '####', 'bridge_mac_ble': '####', 'lock_online': 1, 'webhooks_number': 1, 'ip_address': '10.0.12.120', 'up_timestamp': 1692656610, 'wifi_strength': 97, 'ble_strength': 60} 2023-08-31 09:18:08.473 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for <#####> 2023-08-31 09:18:08.473 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback received: <CIMultiDictProxy('User-Agent': 'ESP32 HTTP Client/1.0', 'Host': '', 'Accept': 'text/html', 'Accept-Encoding': 'identity', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'HASH': 'fcaa28b07385b7cf28036aa786f00d8a28783991672f684aeac9d5024dbc7552', 'TIMESTAMP': '1693466287', 'Content-Length': '161')> 2023-08-31 09:18:08.518 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback body: {"requested_state":"DAY_LOCK","requested_state_numeric":2,"mac_wifi":"####","mac_ble":"####","event_type":"STATE_CHANGED_LATCH","key_local_id":3} 2023-08-31 09:18:08.518 DEBUG (MainThread) [homeassistant.components.loqed.lock] {'battery_percentage': 80, 'battery_type': 'NICKEL_METAL_HYDRIDE', 'battery_type_numeric': 1, 'battery_voltage': 10.412, 'bolt_state': 'night_lock', 'bolt_state_numeric': 3, 'bridge_mac_wifi': '####', 'bridge_mac_ble': '####', 'lock_online': 1, 'webhooks_number': 1, 'ip_address': '10.0.12.120', 'up_timestamp': 1692656610, 'wifi_strength': 97, 'ble_strength': 60}

State: Unlocked. Calling Unlock again: 2023-08-31 09:18:34.215 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for <#####> 2023-08-31 09:18:34.215 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback received: <CIMultiDictProxy('User-Agent': 'ESP32 HTTP Client/1.0', 'Host': '', 'Accept': 'text/html', 'Accept-Encoding': 'identity', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'HASH': '36d04355bcfe567e49953fcad903052df6f67b20cb8c77d4031881f37aa1c132', 'TIMESTAMP': '1693466312', 'Content-Length': '146')> 2023-08-31 09:18:34.260 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback body: {"go_to_state":"DAY_LOCK","event_type":"GO_TO_STATE_MANUAL_LOCK_REMOTE_LATCH","mac_wifi":"####","mac_ble":"####","key_local_id":3} 2023-08-31 09:18:34.260 DEBUG (MainThread) [homeassistant.components.loqed.lock] {'battery_percentage': 80, 'battery_type': 'NICKEL_METAL_HYDRIDE', 'battery_type_numeric': 1, 'battery_voltage': 10.412, 'bolt_state': 'night_lock', 'bolt_state_numeric': 3, 'bridge_mac_wifi': '####', 'bridge_mac_ble': '####', 'lock_online': 1, 'webhooks_number': 1, 'ip_address': '10.0.12.120', 'up_timestamp': 1692656610, 'wifi_strength': 97, 'ble_strength': 60}

-> State stays as "Unlocking". Calling lock:

2023-08-31 09:19:03.109 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for <#####> 2023-08-31 09:19:03.109 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback received: <CIMultiDictProxy('User-Agent': 'ESP32 HTTP Client/1.0', 'Host': '', 'Accept': 'text/html', 'Accept-Encoding': 'identity', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'HASH': '7a8d4f6f5bd26130358560d2395f441d52d03720d21e378ab76e5ea4f840b2fe', 'TIMESTAMP': '1693466341', 'Content-Length': '153')> 2023-08-31 09:19:03.153 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback body: {"go_to_state":"NIGHT_LOCK","event_type":"GO_TO_STATE_MANUAL_LOCK_REMOTE_NIGHT_LOCK","mac_wifi":"####","mac_ble":"####","key_local_id":3} 2023-08-31 09:19:03.154 DEBUG (MainThread) [homeassistant.components.loqed.lock] {'battery_percentage': 80, 'battery_type': 'NICKEL_METAL_HYDRIDE', 'battery_type_numeric': 1, 'battery_voltage': 10.412, 'bolt_state': 'night_lock', 'bolt_state_numeric': 3, 'bridge_mac_wifi': '####', 'bridge_mac_ble': '####', 'lock_online': 1, 'webhooks_number': 1, 'ip_address': '10.0.12.120', 'up_timestamp': 1692656610, 'wifi_strength': 97, 'ble_strength': 60} 2023-08-31 09:19:10.580 DEBUG (MainThread) [homeassistant.components.webhook] Handling webhook POST payload for <#####> 2023-08-31 09:19:10.580 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback received: <CIMultiDictProxy('User-Agent': 'ESP32 HTTP Client/1.0', 'Host': '', 'Accept': 'text/html', 'Accept-Encoding': 'identity', 'Connection': 'keep-alive', 'Content-Type': 'application/json', 'HASH': '4dd8361d372ad920b4eca0d9a832ef25e6a5f49a533bd3d120b71451a0326e17', 'TIMESTAMP': '1693466349', 'Content-Length': '168')> 2023-08-31 09:19:10.625 DEBUG (MainThread) [homeassistant.components.loqed.coordinator] Callback body: {"requested_state":"NIGHT_LOCK","requested_state_numeric":3,"mac_wifi":"####","mac_ble":"####","event_type":"STATE_CHANGED_NIGHT_LOCK","key_local_id":3} 2023-08-31 09:19:10.625 DEBUG (MainThread) [homeassistant.components.loqed.lock] {'battery_percentage': 80, 'battery_type': 'NICKEL_METAL_HYDRIDE', 'battery_type_numeric': 1, 'battery_voltage': 10.412, 'bolt_state': 'night_lock', 'bolt_state_numeric': 3, 'bridge_mac_wifi': '####', 'bridge_mac_ble': '####', 'lock_online': 1, 'webhooks_number': 1, 'ip_address': '10.0.12.120', 'up_timestamp': 1692656610, 'wifi_strength': 97, 'ble_strength': 60}

State: Locked.

Example YAML snippet

No response

Anything in the logs that might be useful for us?

At 2023-08-31 09:18:34.215, after calling Unlock while in Unlocked state, the system does not receive the callback from the lock with the `event_type` stating the current state, so probably it stays in "Unlocking" until next action.

Additional information

No matter the state of the lock, the homeassistant.components.loqed.lock always state the bolt_state is night_lock:

[homeassistant.components.loqed.lock] {'battery_percentage': 80, 'battery_type': 'NICKEL_METAL_HYDRIDE', 'battery_type_numeric': 1, 'battery_voltage': 10.412, 'bolt_state': 'night_lock', 'bolt_state_numeric': 3, 'bridge_mac_wifi': '####', 'bridge_mac_ble': '####', 'lock_online': 1, 'webhooks_number': 1, 'ip_address': '10.0.12.120', 'up_timestamp': 1692656610, 'wifi_strength': 97, 'ble_strength': 60}

home-assistant[bot] commented 1 year ago

Hey there @mikewoudenberg, mind taking a look at this issue as it has been labeled with an integration (loqed) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `loqed` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign loqed` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


loqed documentation loqed source (message by IssueLinks)

hdejongh commented 1 year ago

same problem here.

mikewoudenberg commented 1 year ago

Hmm interesting. The lock's state in home assistant is driven by events coming from the bridge. It seems it is emitting a "transition" event even though the lock is already in the desired state. I'll have to make some adjustments to the webhook handling logic then.

Tobiasn2005 commented 1 year ago

Seems I have the same issue where my lock state change is not pushed to my home assistant instance. Only when I reload the integration the proper state is pulled and shown.