Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions homeassistant/components/matter/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from homeassistant.components.lock import LockEntity, LockEntityDescription
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform
from homeassistant.const import ATTR_CODE, Platform
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback

Expand Down Expand Up @@ -56,11 +56,25 @@ async def send_device_command(

async def async_lock(self, **kwargs: Any) -> None:
"""Lock the lock with pin if needed."""
await self.send_device_command(command=clusters.DoorLock.Commands.LockDoor())
code: str = kwargs.get(
ATTR_CODE,
self._lock_option_default_code,
)
code_bytes = code.encode() if code else None
await self.send_device_command(
command=clusters.DoorLock.Commands.LockDoor(code_bytes)
)

async def async_unlock(self, **kwargs: Any) -> None:
"""Unlock the lock with pin if needed."""
await self.send_device_command(command=clusters.DoorLock.Commands.UnlockDoor())
code: str = kwargs.get(
ATTR_CODE,
self._lock_option_default_code,
)
code_bytes = code.encode() if code else None
await self.send_device_command(
command=clusters.DoorLock.Commands.UnlockDoor(code_bytes)
)

@callback
def _update_from_device(self) -> None:
Expand Down