Add service info for upcloud entities (#61740)

This commit is contained in:
Ville Skyttä 2022-02-22 11:39:09 +02:00 committed by GitHub
parent df9e92b4b8
commit 09e16fa3dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,16 +21,18 @@ from homeassistant.const import (
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.dispatcher import ( from homeassistant.helpers.dispatcher import (
async_dispatcher_connect, async_dispatcher_connect,
async_dispatcher_send, async_dispatcher_send,
) )
from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.update_coordinator import ( from homeassistant.helpers.update_coordinator import (
CoordinatorEntity, CoordinatorEntity,
DataUpdateCoordinator, DataUpdateCoordinator,
) )
from .const import CONFIG_ENTRY_UPDATE_SIGNAL_TEMPLATE, DEFAULT_SCAN_INTERVAL from .const import CONFIG_ENTRY_UPDATE_SIGNAL_TEMPLATE, DEFAULT_SCAN_INTERVAL, DOMAIN
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -177,7 +179,7 @@ class UpCloudServerEntity(CoordinatorEntity):
def __init__( def __init__(
self, self,
coordinator: DataUpdateCoordinator[dict[str, upcloud_api.Server]], coordinator: UpCloudDataUpdateCoordinator,
uuid: str, uuid: str,
) -> None: ) -> None:
"""Initialize the UpCloud server entity.""" """Initialize the UpCloud server entity."""
@ -235,3 +237,17 @@ class UpCloudServerEntity(CoordinatorEntity):
ATTR_MEMORY_AMOUNT, ATTR_MEMORY_AMOUNT,
) )
} }
@property
def device_info(self) -> DeviceInfo:
"""Return info for device registry."""
assert self.coordinator.config_entry is not None
return DeviceInfo(
configuration_url="https://hub.upcloud.com",
default_model="Control Panel",
entry_type=DeviceEntryType.SERVICE,
identifiers={
(DOMAIN, f"{self.coordinator.config_entry.data[CONF_USERNAME]}@hub")
},
manufacturer="UpCloud Ltd",
)