mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Migrate Sonarr to new entity naming style (#79844)
This commit is contained in:
parent
f58e1513e2
commit
c6f28f6d59
@ -12,6 +12,7 @@ CONF_UPCOMING_DAYS = "upcoming_days"
|
||||
CONF_WANTED_MAX_ITEMS = "wanted_max_items"
|
||||
|
||||
# Defaults
|
||||
DEFAULT_NAME = "Sonarr"
|
||||
DEFAULT_UPCOMING_DAYS = 1
|
||||
DEFAULT_VERIFY_SSL = False
|
||||
DEFAULT_WANTED_MAX_ITEMS = 50
|
||||
|
@ -5,13 +5,15 @@ from homeassistant.helpers.device_registry import DeviceEntryType
|
||||
from homeassistant.helpers.entity import DeviceInfo, EntityDescription
|
||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||
|
||||
from .const import DOMAIN
|
||||
from .const import DEFAULT_NAME, DOMAIN
|
||||
from .coordinator import SonarrDataT, SonarrDataUpdateCoordinator
|
||||
|
||||
|
||||
class SonarrEntity(CoordinatorEntity[SonarrDataUpdateCoordinator[SonarrDataT]]):
|
||||
"""Defines a base Sonarr entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: SonarrDataUpdateCoordinator[SonarrDataT],
|
||||
@ -30,7 +32,7 @@ class SonarrEntity(CoordinatorEntity[SonarrDataUpdateCoordinator[SonarrDataT]]):
|
||||
configuration_url=self.coordinator.host_configuration.base_url,
|
||||
entry_type=DeviceEntryType.SERVICE,
|
||||
identifiers={(DOMAIN, self.coordinator.config_entry.entry_id)},
|
||||
manufacturer="Sonarr",
|
||||
name="Activity Sensor",
|
||||
manufacturer=DEFAULT_NAME,
|
||||
name=DEFAULT_NAME,
|
||||
sw_version=self.coordinator.system_version,
|
||||
)
|
||||
|
@ -43,7 +43,7 @@ class SonarrSensorEntityDescription(
|
||||
SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||
"commands": SonarrSensorEntityDescription(
|
||||
key="commands",
|
||||
name="Sonarr Commands",
|
||||
name="Commands",
|
||||
icon="mdi:code-braces",
|
||||
native_unit_of_measurement="Commands",
|
||||
entity_registry_enabled_default=False,
|
||||
@ -51,7 +51,7 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||
),
|
||||
"diskspace": SonarrSensorEntityDescription[list[Diskspace]](
|
||||
key="diskspace",
|
||||
name="Sonarr Disk Space",
|
||||
name="Disk space",
|
||||
icon="mdi:harddisk",
|
||||
native_unit_of_measurement=DATA_GIGABYTES,
|
||||
entity_registry_enabled_default=False,
|
||||
@ -59,7 +59,7 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||
),
|
||||
"queue": SonarrSensorEntityDescription[SonarrQueue](
|
||||
key="queue",
|
||||
name="Sonarr Queue",
|
||||
name="Queue",
|
||||
icon="mdi:download",
|
||||
native_unit_of_measurement="Episodes",
|
||||
entity_registry_enabled_default=False,
|
||||
@ -67,7 +67,7 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||
),
|
||||
"series": SonarrSensorEntityDescription[list[SonarrSeries]](
|
||||
key="series",
|
||||
name="Sonarr Shows",
|
||||
name="Shows",
|
||||
icon="mdi:television",
|
||||
native_unit_of_measurement="Series",
|
||||
entity_registry_enabled_default=False,
|
||||
@ -75,14 +75,14 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||
),
|
||||
"upcoming": SonarrSensorEntityDescription[list[SonarrCalendar]](
|
||||
key="upcoming",
|
||||
name="Sonarr Upcoming",
|
||||
name="Upcoming",
|
||||
icon="mdi:television",
|
||||
native_unit_of_measurement="Episodes",
|
||||
value_fn=len,
|
||||
),
|
||||
"wanted": SonarrSensorEntityDescription[SonarrWantedMissing](
|
||||
key="wanted",
|
||||
name="Sonarr Wanted",
|
||||
name="Wanted",
|
||||
icon="mdi:television",
|
||||
native_unit_of_measurement="Episodes",
|
||||
entity_registry_enabled_default=False,
|
||||
|
Loading…
x
Reference in New Issue
Block a user