"""Generic Plugwise Entity Class."""
from __future__ import annotations

from typing import Any

from homeassistant.const import ATTR_NAME, ATTR_VIA_DEVICE, CONF_HOST
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from .const import DOMAIN
from .coordinator import PlugwiseData, PlugwiseDataUpdateCoordinator


class PlugwiseEntity(CoordinatorEntity[PlugwiseData]):
    """Represent a PlugWise Entity."""

    coordinator: PlugwiseDataUpdateCoordinator

    def __init__(
        self,
        coordinator: PlugwiseDataUpdateCoordinator,
        device_id: str,
    ) -> None:
        """Initialise the gateway."""
        super().__init__(coordinator)
        self._dev_id = device_id

        configuration_url: str | None = None
        if entry := self.coordinator.config_entry:
            configuration_url = f"http://{entry.data[CONF_HOST]}"

        data = coordinator.data.devices[device_id]
        self._attr_device_info = DeviceInfo(
            configuration_url=configuration_url,
            identifiers={(DOMAIN, device_id)},
            manufacturer=data.get("vendor"),
            model=data.get("model"),
            name=f"Smile {coordinator.data.gateway['smile_name']}",
            sw_version=data.get("fw"),
        )

        if device_id != coordinator.data.gateway["gateway_id"]:
            self._attr_device_info.update(
                {
                    ATTR_NAME: data.get("name"),
                    ATTR_VIA_DEVICE: (
                        DOMAIN,
                        str(self.coordinator.data.gateway["gateway_id"]),
                    ),
                }
            )

    @property
    def available(self) -> bool:
        """Return if entity is available."""
        return super().available and self._dev_id in self.coordinator.data.devices

    @property
    def device(self) -> dict[str, Any]:
        """Return data for this device."""
        return self.coordinator.data.devices[self._dev_id]

    async def async_added_to_hass(self) -> None:
        """Subscribe to updates."""
        self._handle_coordinator_update()
        await super().async_added_to_hass()

@@ -160,16 +160,121 @@
 NF_HOST%0A
+from homeassistant.helpers.device_registry import (%0A    CONNECTION_NETWORK_MAC,%0A    CONNECTION_ZIGBEE,%0A)%0A
 from hom
@@ -1076,16 +1076,251 @@
 ice_id%5D%0A
+        connections = set()%0A        if mac := data.get(%22mac_address%22):%0A            connections.add((CONNECTION_NETWORK_MAC, mac))%0A        if mac := data.get(%22zigbee_mac_address%22):%0A            connections.add((CONNECTION_ZIGBEE, mac))%0A%0A
         
@@ -1356,16 +1356,16 @@
 ceInfo(%0A
-
         
@@ -1452,16 +1452,53 @@
 e_id)%7D,%0A
+            connections=connections,%0A
         
@@ -1639,16 +1639,16 @@
 me'%5D%7D%22,%0A
-
         
@@ -1674,24 +1674,63 @@
 .get(%22fw%22),%0A
+            hw_version=data.get(%22hw%22),%0A
         )%0A%0A 

Extend Plugwise DeviceInfo (#66619)