mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Make adding new device in unifiprotect callback functions (#111054)
This commit is contained in:
parent
7eb6614818
commit
b1cbf9840a
@ -591,7 +591,8 @@ async def async_setup_entry(
|
|||||||
"""Set up binary sensors for UniFi Protect integration."""
|
"""Set up binary sensors for UniFi Protect integration."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
entities: list[ProtectDeviceEntity] = async_all_device_entities(
|
entities: list[ProtectDeviceEntity] = async_all_device_entities(
|
||||||
data,
|
data,
|
||||||
ProtectDeviceBinarySensor,
|
ProtectDeviceBinarySensor,
|
||||||
|
@ -113,7 +113,8 @@ async def async_setup_entry(
|
|||||||
"""Discover devices on a UniFi Protect NVR."""
|
"""Discover devices on a UniFi Protect NVR."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
entities = async_all_device_entities(
|
entities = async_all_device_entities(
|
||||||
data,
|
data,
|
||||||
ProtectButton,
|
ProtectButton,
|
||||||
|
@ -113,7 +113,8 @@ async def async_setup_entry(
|
|||||||
"""Discover cameras on a UniFi Protect NVR."""
|
"""Discover cameras on a UniFi Protect NVR."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
if not isinstance(device, UFPCamera):
|
if not isinstance(device, UFPCamera):
|
||||||
return # type: ignore[unreachable]
|
return # type: ignore[unreachable]
|
||||||
|
|
||||||
|
@ -33,7 +33,8 @@ async def async_setup_entry(
|
|||||||
"""Set up lights for UniFi Protect integration."""
|
"""Set up lights for UniFi Protect integration."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
if device.model is ModelType.LIGHT and device.can_write(
|
if device.model is ModelType.LIGHT and device.can_write(
|
||||||
data.api.bootstrap.auth_user
|
data.api.bootstrap.auth_user
|
||||||
):
|
):
|
||||||
|
@ -34,7 +34,8 @@ async def async_setup_entry(
|
|||||||
"""Set up locks on a UniFi Protect NVR."""
|
"""Set up locks on a UniFi Protect NVR."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
if isinstance(device, Doorlock):
|
if isinstance(device, Doorlock):
|
||||||
async_add_entities([ProtectLock(data, device)])
|
async_add_entities([ProtectLock(data, device)])
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ async def async_setup_entry(
|
|||||||
"""Discover cameras with speakers on a UniFi Protect NVR."""
|
"""Discover cameras with speakers on a UniFi Protect NVR."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
if isinstance(device, Camera) and (
|
if isinstance(device, Camera) and (
|
||||||
device.has_speaker or device.has_removable_speaker
|
device.has_speaker or device.has_removable_speaker
|
||||||
):
|
):
|
||||||
|
@ -211,7 +211,8 @@ async def async_setup_entry(
|
|||||||
"""Set up number entities for UniFi Protect integration."""
|
"""Set up number entities for UniFi Protect integration."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
entities = async_all_device_entities(
|
entities = async_all_device_entities(
|
||||||
data,
|
data,
|
||||||
ProtectNumbers,
|
ProtectNumbers,
|
||||||
|
@ -306,7 +306,8 @@ async def async_setup_entry(
|
|||||||
"""Set up number entities for UniFi Protect integration."""
|
"""Set up number entities for UniFi Protect integration."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
entities = async_all_device_entities(
|
entities = async_all_device_entities(
|
||||||
data,
|
data,
|
||||||
ProtectSelects,
|
ProtectSelects,
|
||||||
|
@ -617,7 +617,8 @@ async def async_setup_entry(
|
|||||||
"""Set up sensors for UniFi Protect integration."""
|
"""Set up sensors for UniFi Protect integration."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
entities = async_all_device_entities(
|
entities = async_all_device_entities(
|
||||||
data,
|
data,
|
||||||
ProtectDeviceSensor,
|
ProtectDeviceSensor,
|
||||||
|
@ -442,7 +442,8 @@ async def async_setup_entry(
|
|||||||
"""Set up sensors for UniFi Protect integration."""
|
"""Set up sensors for UniFi Protect integration."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
entities = async_all_device_entities(
|
entities = async_all_device_entities(
|
||||||
data,
|
data,
|
||||||
ProtectSwitch,
|
ProtectSwitch,
|
||||||
|
@ -61,7 +61,8 @@ async def async_setup_entry(
|
|||||||
"""Set up sensors for UniFi Protect integration."""
|
"""Set up sensors for UniFi Protect integration."""
|
||||||
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
data: ProtectData = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
async def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
@callback
|
||||||
|
def _add_new_device(device: ProtectAdoptableDeviceModel) -> None:
|
||||||
entities = async_all_device_entities(
|
entities = async_all_device_entities(
|
||||||
data,
|
data,
|
||||||
ProtectDeviceText,
|
ProtectDeviceText,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user