Skip to content

Commit

Permalink
Add translation to Jellyfin (#123857)
Browse files Browse the repository at this point in the history
* Add translation to Jellyfin

* Fix

* Address feedback
  • Loading branch information
jrieger authored Sep 8, 2024
1 parent 926ffe5 commit c0ee12c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/jellyfin/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ def _count_now_playing(data: JellyfinDataT) -> int:
"sessions": JellyfinSensorEntityDescription(
key="watching",
translation_key="watching",
name=None,
native_unit_of_measurement="Watching",
value_fn=_count_now_playing,
native_unit_of_measurement="clients",
)
}

Expand All @@ -59,6 +58,7 @@ async def async_setup_entry(
class JellyfinSensor(JellyfinEntity, SensorEntity):
"""Defines a Jellyfin sensor entity."""

_attr_has_entity_name = True
entity_description: JellyfinSensorEntityDescription

@property
Expand Down
7 changes: 7 additions & 0 deletions homeassistant/components/jellyfin/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
}
},
"entity": {
"sensor": {
"watching": {
"name": "Active clients"
}
}
},
"options": {
"step": {
"init": {
Expand Down
12 changes: 3 additions & 9 deletions tests/components/jellyfin/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@

from homeassistant.components.jellyfin.const import DOMAIN
from homeassistant.components.sensor import ATTR_STATE_CLASS
from homeassistant.const import (
ATTR_DEVICE_CLASS,
ATTR_FRIENDLY_NAME,
ATTR_ICON,
ATTR_UNIT_OF_MEASUREMENT,
)
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_FRIENDLY_NAME, ATTR_ICON
from homeassistant.core import HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er

Expand All @@ -24,13 +19,12 @@ async def test_watching(
mock_jellyfin: MagicMock,
) -> None:
"""Test the Jellyfin watching sensor."""
state = hass.states.get("sensor.jellyfin_server")
state = hass.states.get("sensor.jellyfin_server_active_clients")
assert state
assert state.attributes.get(ATTR_DEVICE_CLASS) is None
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "JELLYFIN-SERVER"
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "JELLYFIN-SERVER Active clients"
assert state.attributes.get(ATTR_ICON) is None
assert state.attributes.get(ATTR_STATE_CLASS) is None
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Watching"
assert state.state == "3"

entry = entity_registry.async_get(state.entity_id)
Expand Down

0 comments on commit c0ee12c

Please sign in to comment.