mirror of
https://github.com/Electric-Special/ha-core.git
synced 2026-03-21 09:03:13 +01:00
Fix tado via_device warnings (#156884)
This commit is contained in:
committed by
GitHub
parent
2e82ac81b2
commit
a206604df5
@@ -21,7 +21,7 @@ from homeassistant.exceptions import (
|
||||
ConfigEntryError,
|
||||
ConfigEntryNotReady,
|
||||
)
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers import config_validation as cv, device_registry as dr
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
|
||||
from .const import (
|
||||
@@ -32,6 +32,7 @@ from .const import (
|
||||
CONST_OVERLAY_TADO_MODE,
|
||||
CONST_OVERLAY_TADO_OPTIONS,
|
||||
DOMAIN,
|
||||
TADO_BRIDGE_MODELS,
|
||||
)
|
||||
from .coordinator import TadoDataUpdateCoordinator, TadoMobileDeviceUpdateCoordinator
|
||||
from .models import TadoData
|
||||
@@ -105,6 +106,21 @@ async def async_setup_entry(hass: HomeAssistant, entry: TadoConfigEntry) -> bool
|
||||
mobile_coordinator = TadoMobileDeviceUpdateCoordinator(hass, entry, tado)
|
||||
await mobile_coordinator.async_config_entry_first_refresh()
|
||||
|
||||
# Pre-register the bridge device to ensure it exists before other devices reference it
|
||||
device_registry = dr.async_get(hass)
|
||||
for device in coordinator.data["device"].values():
|
||||
if device["deviceType"] in TADO_BRIDGE_MODELS:
|
||||
_LOGGER.debug("Pre-registering Tado bridge: %s", device["shortSerialNo"])
|
||||
device_registry.async_get_or_create(
|
||||
config_entry_id=entry.entry_id,
|
||||
identifiers={(DOMAIN, device["shortSerialNo"])},
|
||||
manufacturer="Tado",
|
||||
model=device["deviceType"],
|
||||
name=device["serialNo"],
|
||||
sw_version=device["currentFwVersion"],
|
||||
configuration_url=f"https://app.tado.com/en/main/settings/rooms-and-devices/device/{device['serialNo']}",
|
||||
)
|
||||
|
||||
entry.runtime_data = TadoData(coordinator, mobile_coordinator)
|
||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||
|
||||
|
||||
@@ -205,6 +205,7 @@ DEFAULT_NAME = "Tado"
|
||||
|
||||
TADO_HOME = "Home"
|
||||
TADO_ZONE = "Zone"
|
||||
TADO_BRIDGE_MODELS = ["IB01", "IB02"]
|
||||
|
||||
# Constants for Temperature Offset
|
||||
INSIDE_TEMPERATURE_MEASUREMENT = "INSIDE_TEMPERATURE_MEASUREMENT"
|
||||
|
||||
@@ -5,7 +5,7 @@ import logging
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DEFAULT_NAME, DOMAIN, TADO_HOME, TADO_ZONE
|
||||
from .const import DEFAULT_NAME, DOMAIN, TADO_BRIDGE_MODELS, TADO_HOME, TADO_ZONE
|
||||
from .coordinator import TadoDataUpdateCoordinator
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -28,6 +28,13 @@ class TadoDeviceEntity(TadoCoordinatorEntity):
|
||||
self._device_info = device_info
|
||||
self.device_name = device_info["serialNo"]
|
||||
self.device_id = device_info["shortSerialNo"]
|
||||
via_device: tuple[str, str] | None = None
|
||||
if device_info["deviceType"] not in TADO_BRIDGE_MODELS:
|
||||
for device in coordinator.data["device"].values():
|
||||
if device["deviceType"] in TADO_BRIDGE_MODELS:
|
||||
via_device = (DOMAIN, device["shortSerialNo"])
|
||||
break
|
||||
|
||||
self._attr_device_info = DeviceInfo(
|
||||
configuration_url=f"https://app.tado.com/en/main/settings/rooms-and-devices/device/{self.device_name}",
|
||||
identifiers={(DOMAIN, self.device_id)},
|
||||
@@ -35,8 +42,9 @@ class TadoDeviceEntity(TadoCoordinatorEntity):
|
||||
manufacturer=DEFAULT_NAME,
|
||||
sw_version=device_info["currentFwVersion"],
|
||||
model=device_info["deviceType"],
|
||||
via_device=(DOMAIN, device_info["serialNo"]),
|
||||
)
|
||||
if via_device:
|
||||
self._attr_device_info["via_device"] = via_device
|
||||
|
||||
|
||||
class TadoHomeEntity(TadoCoordinatorEntity):
|
||||
|
||||
Reference in New Issue
Block a user