mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 16:57:10 +00:00
Matter lock state follow-up (#121669)
This commit is contained in:
parent
33df857283
commit
42003ae5ac
@ -99,7 +99,7 @@ class MatterLock(MatterEntity, LockEntity):
|
|||||||
# the lock should acknowledge the command with an attribute update
|
# the lock should acknowledge the command with an attribute update
|
||||||
# but bad things may happen, so guard against it with a timer.
|
# but bad things may happen, so guard against it with a timer.
|
||||||
self._optimistic_timer = self.hass.loop.call_later(
|
self._optimistic_timer = self.hass.loop.call_later(
|
||||||
5, self._reset_optimistic_state
|
30, self._reset_optimistic_state
|
||||||
)
|
)
|
||||||
code: str | None = kwargs.get(ATTR_CODE)
|
code: str | None = kwargs.get(ATTR_CODE)
|
||||||
code_bytes = code.encode() if code else None
|
code_bytes = code.encode() if code else None
|
||||||
@ -116,7 +116,7 @@ class MatterLock(MatterEntity, LockEntity):
|
|||||||
# the lock should acknowledge the command with an attribute update
|
# the lock should acknowledge the command with an attribute update
|
||||||
# but bad things may happen, so guard against it with a timer.
|
# but bad things may happen, so guard against it with a timer.
|
||||||
self._optimistic_timer = self.hass.loop.call_later(
|
self._optimistic_timer = self.hass.loop.call_later(
|
||||||
5, self._reset_optimistic_state
|
30, self._reset_optimistic_state
|
||||||
)
|
)
|
||||||
code: str | None = kwargs.get(ATTR_CODE)
|
code: str | None = kwargs.get(ATTR_CODE)
|
||||||
code_bytes = code.encode() if code else None
|
code_bytes = code.encode() if code else None
|
||||||
@ -140,7 +140,7 @@ class MatterLock(MatterEntity, LockEntity):
|
|||||||
# the lock should acknowledge the command with an attribute update
|
# the lock should acknowledge the command with an attribute update
|
||||||
# but bad things may happen, so guard against it with a timer.
|
# but bad things may happen, so guard against it with a timer.
|
||||||
self._optimistic_timer = self.hass.loop.call_later(
|
self._optimistic_timer = self.hass.loop.call_later(
|
||||||
5, self._reset_optimistic_state
|
30 if self._attr_is_locked else 5, self._reset_optimistic_state
|
||||||
)
|
)
|
||||||
code: str | None = kwargs.get(ATTR_CODE)
|
code: str | None = kwargs.get(ATTR_CODE)
|
||||||
code_bytes = code.encode() if code else None
|
code_bytes = code.encode() if code else None
|
||||||
|
@ -469,7 +469,7 @@
|
|||||||
"1/47/65531": [
|
"1/47/65531": [
|
||||||
0, 1, 2, 14, 15, 16, 19, 65528, 65529, 65530, 65531, 65532, 65533
|
0, 1, 2, 14, 15, 16, 19, 65528, 65529, 65530, 65531, 65532, 65533
|
||||||
],
|
],
|
||||||
"1/257/0": 1,
|
"1/257/0": 0,
|
||||||
"1/257/1": 0,
|
"1/257/1": 0,
|
||||||
"1/257/2": true,
|
"1/257/2": true,
|
||||||
"1/257/3": 1,
|
"1/257/3": 1,
|
||||||
|
@ -8,11 +8,10 @@ import pytest
|
|||||||
|
|
||||||
from homeassistant.components.lock import (
|
from homeassistant.components.lock import (
|
||||||
STATE_LOCKED,
|
STATE_LOCKED,
|
||||||
STATE_OPEN,
|
|
||||||
STATE_UNLOCKED,
|
STATE_UNLOCKED,
|
||||||
LockEntityFeature,
|
LockEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ATTR_CODE, STATE_LOCKING, STATE_UNKNOWN
|
from homeassistant.const import ATTR_CODE, STATE_LOCKING, STATE_OPENING, STATE_UNKNOWN
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import ServiceValidationError
|
from homeassistant.exceptions import ServiceValidationError
|
||||||
import homeassistant.helpers.entity_registry as er
|
import homeassistant.helpers.entity_registry as er
|
||||||
@ -64,6 +63,7 @@ async def test_lock(
|
|||||||
)
|
)
|
||||||
matter_client.send_device_command.reset_mock()
|
matter_client.send_device_command.reset_mock()
|
||||||
|
|
||||||
|
await hass.async_block_till_done()
|
||||||
state = hass.states.get("lock.mock_door_lock_lock")
|
state = hass.states.get("lock.mock_door_lock_lock")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == STATE_LOCKING
|
assert state.state == STATE_LOCKING
|
||||||
@ -208,9 +208,14 @@ async def test_lock_with_unbolt(
|
|||||||
timed_request_timeout_ms=1000,
|
timed_request_timeout_ms=1000,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
await hass.async_block_till_done()
|
||||||
|
state = hass.states.get("lock.mock_door_lock_lock")
|
||||||
|
assert state
|
||||||
|
assert state.state == STATE_OPENING
|
||||||
|
|
||||||
set_node_attribute(door_lock_with_unbolt, 1, 257, 3, 0)
|
set_node_attribute(door_lock_with_unbolt, 1, 257, 3, 0)
|
||||||
await trigger_subscription_callback(hass, matter_client)
|
await trigger_subscription_callback(hass, matter_client)
|
||||||
|
|
||||||
state = hass.states.get("lock.mock_door_lock_lock")
|
state = hass.states.get("lock.mock_door_lock_lock")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == STATE_OPEN
|
assert state.state == STATE_LOCKED
|
||||||
|
Loading…
x
Reference in New Issue
Block a user