core icon indicating copy to clipboard operation
core copied to clipboard

Locks won't lock or unlock, with or without code

Open mwhdc opened this issue 2 years ago • 2 comments

The problem

Before updating from 2023.1.7 to 2023.2.0b4, locks could be locked and unlocked without a code, or with a valid code. After the 2023.2.0b4 update, locking and unlocking fails, whether or not a code is provided in the service call.

What version of Home Assistant Core has the issue?

core-2023.2.0b4

What was the last working version of Home Assistant Core?

core-2023.1.7

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Lock

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2023-01-30 08:27:13.363 ERROR (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Error executing script. Unexpected error for call_service at pos 1: Code '' for locking Garage Entry doesn't match pattern ^\d5$
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 451, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 684, in _async_call_service_step
    await service_task
  File "/usr/src/homeassistant/homeassistant/core.py", line 1787, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1824, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 681, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 968, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 721, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/lock/__init__.py", line 92, in _async_lock
    raise ValueError(
ValueError: Code '' for locking Garage Entry doesn't match pattern ^\d5$

Additional information

No response

mwhdc avatar Jan 30 '23 13:01 mwhdc

Hey there @home-assistant/core, mind taking a look at this issue as it has been labeled with an integration (lock) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of lock can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Change the title of the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign lock Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


lock documentation lock source (message by IssueLinks)

home-assistant[bot] avatar Jan 30 '23 13:01 home-assistant[bot]

The pattern ^\d5$ would be incorrect. Is this an integration or provided directly by the lock-component?

gjohansson-ST avatar Feb 06 '23 12:02 gjohansson-ST

The pattern ^\d5$ would be incorrect. Is this an integration or provided directly by the lock-component?

Good point, I'm rusty with regex. I'm using Schlage locks via the Hubitat integration. Every lock created by the integration includes the attributes

code_format: ^\d5$
code_length: 5

I'll follow up with the integration's author. Thanks for reviewing the report.

mwhdc avatar Feb 07 '23 18:02 mwhdc

For future reference, an existing bug report for the integration about this issue.

mwhdc avatar Feb 07 '23 18:02 mwhdc