221 files
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from homeassistant.components import homeassistant
|
||||
from homeassistant.const import __version__
|
||||
from homeassistant.helpers.device_registry import DeviceInfo
|
||||
from homeassistant.helpers.device_registry import DeviceEntryType, DeviceInfo
|
||||
from homeassistant.loader import async_get_loaded_integration
|
||||
|
||||
from ...const import DOMAIN
|
||||
from ...entity import SpookEntity, SpookEntityDescription
|
||||
@@ -16,10 +16,21 @@ class HomeAssistantSpookEntity(SpookEntity):
|
||||
def __init__(self, description: SpookEntityDescription) -> None:
|
||||
"""Initialize the entity."""
|
||||
super().__init__(description=description)
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, homeassistant.DOMAIN)},
|
||||
manufacturer="Home Assistant",
|
||||
name="Home Assistant",
|
||||
sw_version=__version__,
|
||||
)
|
||||
self._attr_unique_id = f"{homeassistant.DOMAIN}_{description.key}"
|
||||
|
||||
@property
|
||||
def device_info(self) -> DeviceInfo:
|
||||
"""Return the device, which is Spook's, so it runs Spook's version.
|
||||
|
||||
Read once the entity is added to Home Assistant, as the version comes
|
||||
from the loaded integration.
|
||||
"""
|
||||
version = async_get_loaded_integration(self.hass, DOMAIN).version
|
||||
return DeviceInfo(
|
||||
identifiers={(DOMAIN, homeassistant.DOMAIN)},
|
||||
manufacturer="Spook 👻",
|
||||
name="Home Assistant",
|
||||
sw_version=str(version) if version else None,
|
||||
configuration_url="https://spook.boo/devices-entities",
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user