Entity.device_info typing fixes (#49974)
This commit is contained in:
parent
34320ef617
commit
44a790ab47
4 changed files with 13 additions and 11 deletions
|
@ -5,12 +5,12 @@ import asyncio
|
|||
import functools
|
||||
import logging
|
||||
import math
|
||||
from typing import Any, Callable
|
||||
from typing import Callable
|
||||
|
||||
from aioesphomeapi import (
|
||||
APIClient,
|
||||
APIConnectionError,
|
||||
DeviceInfo,
|
||||
DeviceInfo as EsphomeDeviceInfo,
|
||||
EntityInfo,
|
||||
EntityState,
|
||||
HomeassistantServiceCall,
|
||||
|
@ -36,7 +36,7 @@ from homeassistant.helpers import template
|
|||
import homeassistant.helpers.config_validation as cv
|
||||
import homeassistant.helpers.device_registry as dr
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity import Entity
|
||||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
from homeassistant.helpers.event import async_track_state_change_event
|
||||
from homeassistant.helpers.json import JSONEncoder
|
||||
from homeassistant.helpers.service import async_set_service_schema
|
||||
|
@ -448,7 +448,7 @@ class ReconnectLogic(RecordUpdateListener):
|
|||
|
||||
|
||||
async def _async_setup_device_registry(
|
||||
hass: HomeAssistant, entry: ConfigEntry, device_info: DeviceInfo
|
||||
hass: HomeAssistant, entry: ConfigEntry, device_info: EsphomeDeviceInfo
|
||||
):
|
||||
"""Set up device registry feature for a particular config entry."""
|
||||
sw_version = device_info.esphome_version
|
||||
|
@ -769,7 +769,7 @@ class EsphomeBaseEntity(Entity):
|
|||
return self._entry_data.old_info[self._component_key].get(self._key)
|
||||
|
||||
@property
|
||||
def _device_info(self) -> DeviceInfo:
|
||||
def _device_info(self) -> EsphomeDeviceInfo:
|
||||
return self._entry_data.device_info
|
||||
|
||||
@property
|
||||
|
@ -803,7 +803,7 @@ class EsphomeBaseEntity(Entity):
|
|||
return self._static_info.unique_id
|
||||
|
||||
@property
|
||||
def device_info(self) -> dict[str, Any]:
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return device registry information for this entity."""
|
||||
return {
|
||||
"connections": {(dr.CONNECTION_NETWORK_MAC, self._device_info.mac_address)}
|
||||
|
|
|
@ -16,6 +16,7 @@ from homeassistant.const import (
|
|||
HTTP_OK,
|
||||
)
|
||||
from homeassistant.core import Context, HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.json import JSONEncoder
|
||||
|
||||
from .const import (
|
||||
|
@ -166,12 +167,12 @@ def webhook_response(
|
|||
)
|
||||
|
||||
|
||||
def device_info(registration: dict) -> dict:
|
||||
def device_info(registration: dict) -> DeviceInfo:
|
||||
"""Return the device info for this registration."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, registration[ATTR_DEVICE_ID])},
|
||||
"manufacturer": registration[ATTR_MANUFACTURER],
|
||||
"model": registration[ATTR_MODEL],
|
||||
"device_name": registration[ATTR_DEVICE_NAME],
|
||||
"name": registration[ATTR_DEVICE_NAME],
|
||||
"sw_version": registration[ATTR_OS_VERSION],
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class OneWireBaseEntity(Entity):
|
|||
device_file,
|
||||
entity_type: str,
|
||||
entity_name: str = None,
|
||||
device_info=None,
|
||||
device_info: DeviceInfo | None = None,
|
||||
default_disabled: bool = False,
|
||||
unique_id: str = None,
|
||||
):
|
||||
|
@ -82,7 +82,7 @@ class OneWireProxyEntity(OneWireBaseEntity):
|
|||
self,
|
||||
device_id: str,
|
||||
device_name: str,
|
||||
device_info: dict[str, Any],
|
||||
device_info: DeviceInfo,
|
||||
entity_path: str,
|
||||
entity_specs: dict[str, Any],
|
||||
owproxy: protocol._Proxy,
|
||||
|
|
|
@ -8,6 +8,7 @@ from starline import StarlineApi, StarlineDevice
|
|||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.event import async_track_time_interval
|
||||
|
||||
from .const import (
|
||||
|
@ -125,7 +126,7 @@ class StarlineAccount:
|
|||
self._unsubscribe_auto_obd_updater = None
|
||||
|
||||
@staticmethod
|
||||
def device_info(device: StarlineDevice) -> dict[str, Any]:
|
||||
def device_info(device: StarlineDevice) -> DeviceInfo:
|
||||
"""Device information for entities."""
|
||||
return {
|
||||
"identifiers": {(DOMAIN, device.device_id)},
|
||||
|
|
Loading…
Add table
Reference in a new issue