mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 09:47:52 +00:00
Move async_client_device_info_fn to entity.py (#97270)
Move client device info
This commit is contained in:
parent
f610a9b1c9
commit
e99ba1b0da
@ -74,6 +74,17 @@ def async_wlan_device_info_fn(api: aiounifi.Controller, obj_id: str) -> DeviceIn
|
||||
)
|
||||
|
||||
|
||||
@callback
|
||||
def async_client_device_info_fn(api: aiounifi.Controller, obj_id: str) -> DeviceInfo:
|
||||
"""Create device registry entry for client."""
|
||||
client = api.clients[obj_id]
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, obj_id)},
|
||||
default_manufacturer=client.oui,
|
||||
default_name=client.name or client.hostname,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class UnifiDescription(Generic[HandlerT, ApiItemT]):
|
||||
"""Validate and load entities from different UniFi handlers."""
|
||||
|
@ -10,7 +10,6 @@ from dataclasses import dataclass
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Generic
|
||||
|
||||
import aiounifi
|
||||
from aiounifi.interfaces.api_handlers import ItemEvent
|
||||
from aiounifi.interfaces.clients import Clients
|
||||
from aiounifi.interfaces.ports import Ports
|
||||
@ -28,8 +27,6 @@ from homeassistant.components.sensor import (
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import EntityCategory, UnitOfInformation, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import CONNECTION_NETWORK_MAC
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
@ -39,6 +36,7 @@ from .entity import (
|
||||
HandlerT,
|
||||
UnifiEntity,
|
||||
UnifiEntityDescription,
|
||||
async_client_device_info_fn,
|
||||
async_device_available_fn,
|
||||
async_device_device_info_fn,
|
||||
async_wlan_device_info_fn,
|
||||
@ -83,17 +81,6 @@ def async_wlan_client_value_fn(controller: UniFiController, wlan: Wlan) -> int:
|
||||
)
|
||||
|
||||
|
||||
@callback
|
||||
def async_client_device_info_fn(api: aiounifi.Controller, obj_id: str) -> DeviceInfo:
|
||||
"""Create device registry entry for client."""
|
||||
client = api.clients[obj_id]
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, obj_id)},
|
||||
default_manufacturer=client.oui,
|
||||
default_name=client.name or client.hostname,
|
||||
)
|
||||
|
||||
|
||||
@dataclass
|
||||
class UnifiSensorEntityDescriptionMixin(Generic[HandlerT, ApiItemT]):
|
||||
"""Validate and load entities from different UniFi handlers."""
|
||||
|
@ -42,7 +42,6 @@ from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import EntityCategory
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.device_registry import (
|
||||
CONNECTION_NETWORK_MAC,
|
||||
DeviceEntryType,
|
||||
)
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
@ -55,6 +54,7 @@ from .entity import (
|
||||
SubscriptionT,
|
||||
UnifiEntity,
|
||||
UnifiEntityDescription,
|
||||
async_client_device_info_fn,
|
||||
async_device_available_fn,
|
||||
async_device_device_info_fn,
|
||||
async_wlan_device_info_fn,
|
||||
@ -77,17 +77,6 @@ def async_dpi_group_is_on_fn(
|
||||
)
|
||||
|
||||
|
||||
@callback
|
||||
def async_client_device_info_fn(api: aiounifi.Controller, obj_id: str) -> DeviceInfo:
|
||||
"""Create device registry entry for client."""
|
||||
client = api.clients[obj_id]
|
||||
return DeviceInfo(
|
||||
connections={(CONNECTION_NETWORK_MAC, obj_id)},
|
||||
default_manufacturer=client.oui,
|
||||
default_name=client.name or client.hostname,
|
||||
)
|
||||
|
||||
|
||||
@callback
|
||||
def async_dpi_group_device_info_fn(api: aiounifi.Controller, obj_id: str) -> DeviceInfo:
|
||||
"""Create device registry entry for DPI group."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user