core: Default pin code for locks no longer work

The problem

Looks like the code format change in the latest release commit #87323 has caused the default pin code for locks to stop working.

Locking and unlocking without providing a pin code throws error “Failed to call service lock/unlock for unlocking None doesn’t match pattern ^\d{4}$”

In the past the yale integration would use the default pin code I provided. As stated in the documentation.

I have tried resetting the default pin and it’s still failing

Thank you

What version of Home Assistant Core has the issue?

2023.2.2

What was the last working version of Home Assistant Core?

2023.1.7

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Yale Smart Living

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.websocket_api.http.connection
Source: components/lock/__init__.py:102
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 3:52:56 PM (9 occurrences)
Last logged: 4:16:41 PM

[140578182761824] Code '' for unlocking None doesn't match pattern ^\d{4}$
[140577929891024] Code '' for unlocking None doesn't match pattern ^\d{4}$
[140577784535392] Code '' for unlocking None doesn't match pattern ^\d{4}$
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  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 680, 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 720, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/scene/__init__.py", line 114, in _async_activate
    await self.async_activate(**kwargs)
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/scene.py", line 334, in async_activate
    await async_reproduce_state(
  File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 115, in async_reproduce_state
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/helpers/state.py", line 109, in worker
    await platform.async_reproduce_states(
  File "/usr/src/homeassistant/homeassistant/components/lock/reproduce_state.py", line 69, in async_reproduce_states
    await asyncio.gather(
  File "/usr/src/homeassistant/homeassistant/components/lock/reproduce_state.py", line 56, in _async_reproduce_state
    await hass.services.async_call(
  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 680, 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 720, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/components/lock/__init__.py", line 102, in _async_unlock
    raise ValueError(
ValueError: Code '' for unlocking None doesn't match pattern ^\d{4}$

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 19 (6 by maintainers)

Most upvoted comments

Ah understood, so code will always need to input manually now? Makes things like the mushroom lock card a bit pointless 😦

No, go to the lock entity and open it’s settings and there is a new field for defining a default code.

This is fixed in 2023.6 version for lock to set a default code on the entity. Same solution will likely be made for alarm_control_panel.