hass-core/homeassistant/components/sonarr/entity.py

42 lines
1.3 KiB
Python
Raw Normal View History

"""Base Entity for Sonarr."""
2022-02-22 11:33:10 -06:00
from aiopyarr import SystemStatus
from aiopyarr.models.host_configuration import PyArrHostConfiguration
from aiopyarr.sonarr_client import SonarrClient
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity import DeviceInfo, Entity
from .const import DOMAIN
class SonarrEntity(Entity):
"""Defines a base Sonarr entity."""
def __init__(
self,
*,
2022-02-22 11:33:10 -06:00
sonarr: SonarrClient,
host_config: PyArrHostConfiguration,
system_status: SystemStatus,
entry_id: str,
device_id: str,
) -> None:
"""Initialize the Sonarr entity."""
self._entry_id = entry_id
self._device_id = device_id
self.sonarr = sonarr
2022-02-22 11:33:10 -06:00
self.host_config = host_config
self.system_status = system_status
@property
2022-10-07 13:08:08 -04:00
def device_info(self) -> DeviceInfo:
"""Return device information about the application."""
return DeviceInfo(
identifiers={(DOMAIN, self._device_id)},
name="Activity Sensor",
manufacturer="Sonarr",
2022-02-22 11:33:10 -06:00
sw_version=self.system_status.version,
entry_type=DeviceEntryType.SERVICE,
2022-02-22 11:33:10 -06:00
configuration_url=self.host_config.base_url,
)