mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Register Airzone WebServer device (#135538)
This commit is contained in:
parent
984c380e13
commit
ca34541b04
@ -5,7 +5,14 @@ from __future__ import annotations
|
|||||||
import logging
|
import logging
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aioairzone.const import AZD_MAC, AZD_WEBSERVER, DEFAULT_SYSTEM_ID
|
from aioairzone.const import (
|
||||||
|
AZD_FIRMWARE,
|
||||||
|
AZD_FULL_NAME,
|
||||||
|
AZD_MAC,
|
||||||
|
AZD_MODEL,
|
||||||
|
AZD_WEBSERVER,
|
||||||
|
DEFAULT_SYSTEM_ID,
|
||||||
|
)
|
||||||
from aioairzone.localapi import AirzoneLocalApi, ConnectionOptions
|
from aioairzone.localapi import AirzoneLocalApi, ConnectionOptions
|
||||||
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -17,6 +24,7 @@ from homeassistant.helpers import (
|
|||||||
entity_registry as er,
|
entity_registry as er,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from .const import DOMAIN, MANUFACTURER
|
||||||
from .coordinator import AirzoneUpdateCoordinator
|
from .coordinator import AirzoneUpdateCoordinator
|
||||||
|
|
||||||
PLATFORMS: list[Platform] = [
|
PLATFORMS: list[Platform] = [
|
||||||
@ -88,6 +96,22 @@ async def async_setup_entry(hass: HomeAssistant, entry: AirzoneConfigEntry) -> b
|
|||||||
|
|
||||||
entry.runtime_data = coordinator
|
entry.runtime_data = coordinator
|
||||||
|
|
||||||
|
device_registry = dr.async_get(hass)
|
||||||
|
|
||||||
|
ws_data: dict[str, Any] | None = coordinator.data.get(AZD_WEBSERVER)
|
||||||
|
if ws_data is not None:
|
||||||
|
mac = ws_data.get(AZD_MAC, "")
|
||||||
|
|
||||||
|
device_registry.async_get_or_create(
|
||||||
|
config_entry_id=entry.entry_id,
|
||||||
|
connections={(dr.CONNECTION_NETWORK_MAC, mac)},
|
||||||
|
identifiers={(DOMAIN, f"{entry.entry_id}_ws")},
|
||||||
|
manufacturer=MANUFACTURER,
|
||||||
|
model=ws_data.get(AZD_MODEL),
|
||||||
|
name=ws_data.get(AZD_FULL_NAME),
|
||||||
|
sw_version=ws_data.get(AZD_FIRMWARE),
|
||||||
|
)
|
||||||
|
|
||||||
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
@ -68,8 +68,9 @@ class AirzoneSystemEntity(AirzoneEntity):
|
|||||||
model=self.get_airzone_value(AZD_MODEL),
|
model=self.get_airzone_value(AZD_MODEL),
|
||||||
name=f"System {self.system_id}",
|
name=f"System {self.system_id}",
|
||||||
sw_version=self.get_airzone_value(AZD_FIRMWARE),
|
sw_version=self.get_airzone_value(AZD_FIRMWARE),
|
||||||
via_device=(DOMAIN, f"{entry.entry_id}_ws"),
|
|
||||||
)
|
)
|
||||||
|
if AZD_WEBSERVER in self.coordinator.data:
|
||||||
|
self._attr_device_info["via_device"] = (DOMAIN, f"{entry.entry_id}_ws")
|
||||||
self._attr_unique_id = entry.unique_id or entry.entry_id
|
self._attr_unique_id = entry.unique_id or entry.entry_id
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -102,8 +103,9 @@ class AirzoneHotWaterEntity(AirzoneEntity):
|
|||||||
manufacturer=MANUFACTURER,
|
manufacturer=MANUFACTURER,
|
||||||
model="DHW",
|
model="DHW",
|
||||||
name=self.get_airzone_value(AZD_NAME),
|
name=self.get_airzone_value(AZD_NAME),
|
||||||
via_device=(DOMAIN, f"{entry.entry_id}_ws"),
|
|
||||||
)
|
)
|
||||||
|
if AZD_WEBSERVER in self.coordinator.data:
|
||||||
|
self._attr_device_info["via_device"] = (DOMAIN, f"{entry.entry_id}_ws")
|
||||||
self._attr_unique_id = entry.unique_id or entry.entry_id
|
self._attr_unique_id = entry.unique_id or entry.entry_id
|
||||||
|
|
||||||
def get_airzone_value(self, key: str) -> Any:
|
def get_airzone_value(self, key: str) -> Any:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user