mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Migrate Tautulli to new entity naming style (#75382)
This commit is contained in:
parent
45d1f8bc55
commit
9f33a0d6dd
@ -46,6 +46,8 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
||||
class TautulliEntity(CoordinatorEntity[TautulliDataUpdateCoordinator]):
|
||||
"""Defines a base Tautulli entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
coordinator: TautulliDataUpdateCoordinator,
|
||||
|
@ -60,14 +60,14 @@ SENSOR_TYPES: tuple[TautulliSensorEntityDescription, ...] = (
|
||||
TautulliSensorEntityDescription(
|
||||
icon="mdi:plex",
|
||||
key="watching_count",
|
||||
name="Tautulli",
|
||||
name="Watching",
|
||||
native_unit_of_measurement="Watching",
|
||||
value_fn=lambda home_stats, activity, _: cast(int, activity.stream_count),
|
||||
),
|
||||
TautulliSensorEntityDescription(
|
||||
icon="mdi:plex",
|
||||
key="stream_count_direct_play",
|
||||
name="Direct Plays",
|
||||
name="Direct plays",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
native_unit_of_measurement="Streams",
|
||||
entity_registry_enabled_default=False,
|
||||
@ -78,7 +78,7 @@ SENSOR_TYPES: tuple[TautulliSensorEntityDescription, ...] = (
|
||||
TautulliSensorEntityDescription(
|
||||
icon="mdi:plex",
|
||||
key="stream_count_direct_stream",
|
||||
name="Direct Streams",
|
||||
name="Direct streams",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
native_unit_of_measurement="Streams",
|
||||
entity_registry_enabled_default=False,
|
||||
@ -99,7 +99,7 @@ SENSOR_TYPES: tuple[TautulliSensorEntityDescription, ...] = (
|
||||
),
|
||||
TautulliSensorEntityDescription(
|
||||
key="total_bandwidth",
|
||||
name="Total Bandwidth",
|
||||
name="Total bandwidth",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
native_unit_of_measurement=DATA_KILOBITS,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
@ -107,7 +107,7 @@ SENSOR_TYPES: tuple[TautulliSensorEntityDescription, ...] = (
|
||||
),
|
||||
TautulliSensorEntityDescription(
|
||||
key="lan_bandwidth",
|
||||
name="LAN Bandwidth",
|
||||
name="LAN bandwidth",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
native_unit_of_measurement=DATA_KILOBITS,
|
||||
entity_registry_enabled_default=False,
|
||||
@ -116,7 +116,7 @@ SENSOR_TYPES: tuple[TautulliSensorEntityDescription, ...] = (
|
||||
),
|
||||
TautulliSensorEntityDescription(
|
||||
key="wan_bandwidth",
|
||||
name="WAN Bandwidth",
|
||||
name="WAN bandwidth",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
native_unit_of_measurement=DATA_KILOBITS,
|
||||
entity_registry_enabled_default=False,
|
||||
@ -126,21 +126,21 @@ SENSOR_TYPES: tuple[TautulliSensorEntityDescription, ...] = (
|
||||
TautulliSensorEntityDescription(
|
||||
icon="mdi:movie-open",
|
||||
key="top_movies",
|
||||
name="Top Movie",
|
||||
name="Top movie",
|
||||
entity_registry_enabled_default=False,
|
||||
value_fn=get_top_stats,
|
||||
),
|
||||
TautulliSensorEntityDescription(
|
||||
icon="mdi:television",
|
||||
key="top_tv",
|
||||
name="Top TV Show",
|
||||
name="Top TV show",
|
||||
entity_registry_enabled_default=False,
|
||||
value_fn=get_top_stats,
|
||||
),
|
||||
TautulliSensorEntityDescription(
|
||||
icon="mdi:walk",
|
||||
key=ATTR_TOP_USER,
|
||||
name="Top User",
|
||||
name="Top user",
|
||||
entity_registry_enabled_default=False,
|
||||
value_fn=get_top_stats,
|
||||
),
|
||||
@ -170,7 +170,7 @@ SESSION_SENSOR_TYPES: tuple[TautulliSessionSensorEntityDescription, ...] = (
|
||||
),
|
||||
TautulliSessionSensorEntityDescription(
|
||||
key="full_title",
|
||||
name="Full Title",
|
||||
name="Full title",
|
||||
entity_registry_enabled_default=False,
|
||||
value_fn=lambda session: cast(str, session.full_title),
|
||||
),
|
||||
@ -184,7 +184,7 @@ SESSION_SENSOR_TYPES: tuple[TautulliSessionSensorEntityDescription, ...] = (
|
||||
),
|
||||
TautulliSessionSensorEntityDescription(
|
||||
key="stream_resolution",
|
||||
name="Stream Resolution",
|
||||
name="Stream resolution",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
value_fn=lambda session: cast(str, session.stream_video_resolution),
|
||||
@ -192,21 +192,21 @@ SESSION_SENSOR_TYPES: tuple[TautulliSessionSensorEntityDescription, ...] = (
|
||||
TautulliSessionSensorEntityDescription(
|
||||
icon="mdi:plex",
|
||||
key="transcode_decision",
|
||||
name="Transcode Decision",
|
||||
name="Transcode decision",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
value_fn=lambda session: cast(str, session.transcode_decision),
|
||||
),
|
||||
TautulliSessionSensorEntityDescription(
|
||||
key="session_thumb",
|
||||
name="session Thumbnail",
|
||||
name="session thumbnail",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
value_fn=lambda session: cast(str, session.user_thumb),
|
||||
),
|
||||
TautulliSessionSensorEntityDescription(
|
||||
key="video_resolution",
|
||||
name="Video Resolution",
|
||||
name="Video resolution",
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
entity_registry_enabled_default=False,
|
||||
value_fn=lambda session: cast(str, session.video_resolution),
|
||||
@ -284,7 +284,6 @@ class TautulliSessionSensor(TautulliEntity, SensorEntity):
|
||||
super().__init__(coordinator, description, user)
|
||||
entry_id = coordinator.config_entry.entry_id
|
||||
self._attr_unique_id = f"{entry_id}_{user.user_id}_{description.key}"
|
||||
self._attr_name = f"{user.username} {description.name}"
|
||||
|
||||
@property
|
||||
def native_value(self) -> StateType:
|
||||
|
Loading…
x
Reference in New Issue
Block a user