Refactor and unify device fetching for UniFi Protect (#77341)

This commit is contained in:
Christopher Bailey 2022-08-26 07:46:11 -04:00 committed by GitHub
parent dfc3e7d80f
commit 1fb8fbf5de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 50 additions and 44 deletions

View file

@ -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)