Automatically add newly added devices for UniFi Protect (#73879)

This commit is contained in:
Christopher Bailey 2022-06-27 17:03:25 -04:00 committed by GitHub
parent 33f5b225fb
commit b9c636ba4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 696 additions and 76 deletions

View file

@ -15,9 +15,10 @@ from pyunifiprotect.data import (
ProtectAdoptableDeviceModel,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
from .const import ModelType
from .const import DOMAIN, ModelType
def get_nested_attr(obj: Any, attr: str) -> Any:
@ -98,3 +99,10 @@ def async_get_light_motion_current(obj: Light) -> str:
):
return f"{LightModeType.MOTION.value}Dark"
return obj.light_mode_settings.mode.value
@callback
def async_dispatch_id(entry: ConfigEntry, dispatch: str) -> str:
"""Generate entry specific dispatch ID."""
return f"{DOMAIN}.{entry.entry_id}.{dispatch}"