mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Address small review comments in ESPHome (#85770)
This commit is contained in:
parent
686258acd5
commit
9415e7e51b
@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
import asyncio
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
import aiohttp
|
||||
from esphome_dashboard_api import ConfiguredDevice, ESPHomeDashboardAPI
|
||||
@ -13,9 +12,6 @@ from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.aiohttp_client import async_get_clientsession
|
||||
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
|
||||
|
||||
if TYPE_CHECKING:
|
||||
pass
|
||||
|
||||
KEY_DASHBOARD = "esphome_dashboard"
|
||||
|
||||
|
||||
|
@ -43,7 +43,7 @@ SAVE_DELAY = 120
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
# Mapping from ESPHome info type to HA platform
|
||||
INFO_TYPE_TO_PLATFORM: dict[type[EntityInfo], str] = {
|
||||
INFO_TYPE_TO_PLATFORM: dict[type[EntityInfo], Platform] = {
|
||||
BinarySensorInfo: Platform.BINARY_SENSOR,
|
||||
ButtonInfo: Platform.BUTTON,
|
||||
CameraInfo: Platform.CAMERA,
|
||||
@ -86,7 +86,7 @@ class RuntimeEntryData:
|
||||
state_subscriptions: dict[
|
||||
tuple[type[EntityState], int], Callable[[], None]
|
||||
] = field(default_factory=dict)
|
||||
loaded_platforms: set[str] = field(default_factory=set)
|
||||
loaded_platforms: set[Platform] = field(default_factory=set)
|
||||
platform_load_lock: asyncio.Lock = field(default_factory=asyncio.Lock)
|
||||
_storage_contents: dict[str, Any] | None = None
|
||||
ble_connections_free: int = 0
|
||||
@ -135,7 +135,7 @@ class RuntimeEntryData:
|
||||
async_dispatcher_send(hass, signal)
|
||||
|
||||
async def _ensure_platforms_loaded(
|
||||
self, hass: HomeAssistant, entry: ConfigEntry, platforms: set[str]
|
||||
self, hass: HomeAssistant, entry: ConfigEntry, platforms: set[Platform]
|
||||
) -> None:
|
||||
async with self.platform_load_lock:
|
||||
needed = platforms - self.loaded_platforms
|
||||
@ -151,7 +151,7 @@ class RuntimeEntryData:
|
||||
needed_platforms = set()
|
||||
|
||||
if async_get_dashboard(hass):
|
||||
needed_platforms.add("update")
|
||||
needed_platforms.add(Platform.UPDATE)
|
||||
|
||||
for info in infos:
|
||||
for info_type, platform in INFO_TYPE_TO_PLATFORM.items():
|
||||
|
@ -78,7 +78,7 @@ class ESPHomeUpdateEntity(CoordinatorEntity[ESPHomeDashboard], UpdateEntity):
|
||||
super().__init__(coordinator=coordinator)
|
||||
assert entry_data.device_info is not None
|
||||
self._device_info = entry_data.device_info
|
||||
self._attr_unique_id = f"{entry_data.entry_id}_update"
|
||||
self._attr_unique_id = entry_data.device_info.mac_address
|
||||
self._attr_device_info = DeviceInfo(
|
||||
connections={
|
||||
(dr.CONNECTION_NETWORK_MAC, entry_data.device_info.mac_address)
|
||||
|
Loading…
x
Reference in New Issue
Block a user