Refactor and unify device fetching for UniFi Protect (#77341)
This commit is contained in:
parent
dfc3e7d80f
commit
1fb8fbf5de
10 changed files with 50 additions and 44 deletions
|
@ -2,11 +2,12 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
from typing import Any, cast
|
||||
|
||||
from pyunifiprotect.data import (
|
||||
Doorlock,
|
||||
LockStatusType,
|
||||
ModelType,
|
||||
ProtectAdoptableDeviceModel,
|
||||
ProtectModelWithId,
|
||||
)
|
||||
|
@ -42,10 +43,8 @@ async def async_setup_entry(
|
|||
)
|
||||
|
||||
entities = []
|
||||
for device in data.api.bootstrap.doorlocks.values():
|
||||
if not device.is_adopted_by_us:
|
||||
continue
|
||||
|
||||
for device in data.get_by_types({ModelType.DOORLOCK}):
|
||||
device = cast(Doorlock, device)
|
||||
entities.append(ProtectLock(data, device))
|
||||
|
||||
async_add_entities(entities)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue