Migrate Sonarr to new entity naming style (#79844)
This commit is contained in:
parent
f58e1513e2
commit
c6f28f6d59
3 changed files with 12 additions and 9 deletions
|
@ -12,6 +12,7 @@ CONF_UPCOMING_DAYS = "upcoming_days"
|
||||||
CONF_WANTED_MAX_ITEMS = "wanted_max_items"
|
CONF_WANTED_MAX_ITEMS = "wanted_max_items"
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
|
DEFAULT_NAME = "Sonarr"
|
||||||
DEFAULT_UPCOMING_DAYS = 1
|
DEFAULT_UPCOMING_DAYS = 1
|
||||||
DEFAULT_VERIFY_SSL = False
|
DEFAULT_VERIFY_SSL = False
|
||||||
DEFAULT_WANTED_MAX_ITEMS = 50
|
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.entity import DeviceInfo, EntityDescription
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
||||||
|
|
||||||
from .const import DOMAIN
|
from .const import DEFAULT_NAME, DOMAIN
|
||||||
from .coordinator import SonarrDataT, SonarrDataUpdateCoordinator
|
from .coordinator import SonarrDataT, SonarrDataUpdateCoordinator
|
||||||
|
|
||||||
|
|
||||||
class SonarrEntity(CoordinatorEntity[SonarrDataUpdateCoordinator[SonarrDataT]]):
|
class SonarrEntity(CoordinatorEntity[SonarrDataUpdateCoordinator[SonarrDataT]]):
|
||||||
"""Defines a base Sonarr entity."""
|
"""Defines a base Sonarr entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: SonarrDataUpdateCoordinator[SonarrDataT],
|
coordinator: SonarrDataUpdateCoordinator[SonarrDataT],
|
||||||
|
@ -30,7 +32,7 @@ class SonarrEntity(CoordinatorEntity[SonarrDataUpdateCoordinator[SonarrDataT]]):
|
||||||
configuration_url=self.coordinator.host_configuration.base_url,
|
configuration_url=self.coordinator.host_configuration.base_url,
|
||||||
entry_type=DeviceEntryType.SERVICE,
|
entry_type=DeviceEntryType.SERVICE,
|
||||||
identifiers={(DOMAIN, self.coordinator.config_entry.entry_id)},
|
identifiers={(DOMAIN, self.coordinator.config_entry.entry_id)},
|
||||||
manufacturer="Sonarr",
|
manufacturer=DEFAULT_NAME,
|
||||||
name="Activity Sensor",
|
name=DEFAULT_NAME,
|
||||||
sw_version=self.coordinator.system_version,
|
sw_version=self.coordinator.system_version,
|
||||||
)
|
)
|
||||||
|
|
|
@ -43,7 +43,7 @@ class SonarrSensorEntityDescription(
|
||||||
SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
"commands": SonarrSensorEntityDescription(
|
"commands": SonarrSensorEntityDescription(
|
||||||
key="commands",
|
key="commands",
|
||||||
name="Sonarr Commands",
|
name="Commands",
|
||||||
icon="mdi:code-braces",
|
icon="mdi:code-braces",
|
||||||
native_unit_of_measurement="Commands",
|
native_unit_of_measurement="Commands",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
@ -51,7 +51,7 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
),
|
),
|
||||||
"diskspace": SonarrSensorEntityDescription[list[Diskspace]](
|
"diskspace": SonarrSensorEntityDescription[list[Diskspace]](
|
||||||
key="diskspace",
|
key="diskspace",
|
||||||
name="Sonarr Disk Space",
|
name="Disk space",
|
||||||
icon="mdi:harddisk",
|
icon="mdi:harddisk",
|
||||||
native_unit_of_measurement=DATA_GIGABYTES,
|
native_unit_of_measurement=DATA_GIGABYTES,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
@ -59,7 +59,7 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
),
|
),
|
||||||
"queue": SonarrSensorEntityDescription[SonarrQueue](
|
"queue": SonarrSensorEntityDescription[SonarrQueue](
|
||||||
key="queue",
|
key="queue",
|
||||||
name="Sonarr Queue",
|
name="Queue",
|
||||||
icon="mdi:download",
|
icon="mdi:download",
|
||||||
native_unit_of_measurement="Episodes",
|
native_unit_of_measurement="Episodes",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
@ -67,7 +67,7 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
),
|
),
|
||||||
"series": SonarrSensorEntityDescription[list[SonarrSeries]](
|
"series": SonarrSensorEntityDescription[list[SonarrSeries]](
|
||||||
key="series",
|
key="series",
|
||||||
name="Sonarr Shows",
|
name="Shows",
|
||||||
icon="mdi:television",
|
icon="mdi:television",
|
||||||
native_unit_of_measurement="Series",
|
native_unit_of_measurement="Series",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
@ -75,14 +75,14 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
),
|
),
|
||||||
"upcoming": SonarrSensorEntityDescription[list[SonarrCalendar]](
|
"upcoming": SonarrSensorEntityDescription[list[SonarrCalendar]](
|
||||||
key="upcoming",
|
key="upcoming",
|
||||||
name="Sonarr Upcoming",
|
name="Upcoming",
|
||||||
icon="mdi:television",
|
icon="mdi:television",
|
||||||
native_unit_of_measurement="Episodes",
|
native_unit_of_measurement="Episodes",
|
||||||
value_fn=len,
|
value_fn=len,
|
||||||
),
|
),
|
||||||
"wanted": SonarrSensorEntityDescription[SonarrWantedMissing](
|
"wanted": SonarrSensorEntityDescription[SonarrWantedMissing](
|
||||||
key="wanted",
|
key="wanted",
|
||||||
name="Sonarr Wanted",
|
name="Wanted",
|
||||||
icon="mdi:television",
|
icon="mdi:television",
|
||||||
native_unit_of_measurement="Episodes",
|
native_unit_of_measurement="Episodes",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
|
Loading…
Add table
Reference in a new issue