Add new locks automatically to tedee integration (#107372)
* remove removed locks * move duplicated code to function * remove entities by removing device * add new locks automatically * add locks from coordinator * remove other PR stuff * add pullspring lock to test for coverage * requested changes
This commit is contained in:
parent
d6aaaf1f1a
commit
7385da626e
9 changed files with 127 additions and 2 deletions
|
@ -3,6 +3,7 @@ from datetime import timedelta
|
|||
from unittest.mock import MagicMock
|
||||
|
||||
from freezegun.api import FrozenDateTimeFactory
|
||||
from pytedee_async import TedeeLock
|
||||
from pytedee_async.exception import (
|
||||
TedeeClientException,
|
||||
TedeeDataUpdateException,
|
||||
|
@ -207,3 +208,31 @@ async def test_update_failed(
|
|||
state = hass.states.get("lock.lock_1a2b")
|
||||
assert state is not None
|
||||
assert state.state == STATE_UNAVAILABLE
|
||||
|
||||
|
||||
async def test_new_lock(
|
||||
hass: HomeAssistant,
|
||||
mock_tedee: MagicMock,
|
||||
freezer: FrozenDateTimeFactory,
|
||||
) -> None:
|
||||
"""Ensure new lock is added automatically."""
|
||||
|
||||
state = hass.states.get("lock.lock_4e5f")
|
||||
assert state is None
|
||||
|
||||
mock_tedee.locks_dict[666666] = TedeeLock("Lock-4E5F", 666666, 2)
|
||||
mock_tedee.locks_dict[777777] = TedeeLock(
|
||||
"Lock-6G7H",
|
||||
777777,
|
||||
4,
|
||||
is_enabled_pullspring=True,
|
||||
)
|
||||
|
||||
freezer.tick(timedelta(minutes=10))
|
||||
async_fire_time_changed(hass)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
state = hass.states.get("lock.lock_4e5f")
|
||||
assert state
|
||||
state = hass.states.get("lock.lock_6g7h")
|
||||
assert state
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue