mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Add translation to Jellyfin (#123857)
* Add translation to Jellyfin * Fix * Address feedback
This commit is contained in:
parent
926ffe536c
commit
c0ee12ca41
@ -35,9 +35,8 @@ SENSOR_TYPES: dict[str, JellyfinSensorEntityDescription] = {
|
|||||||
"sessions": JellyfinSensorEntityDescription(
|
"sessions": JellyfinSensorEntityDescription(
|
||||||
key="watching",
|
key="watching",
|
||||||
translation_key="watching",
|
translation_key="watching",
|
||||||
name=None,
|
|
||||||
native_unit_of_measurement="Watching",
|
|
||||||
value_fn=_count_now_playing,
|
value_fn=_count_now_playing,
|
||||||
|
native_unit_of_measurement="clients",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +58,7 @@ async def async_setup_entry(
|
|||||||
class JellyfinSensor(JellyfinEntity, SensorEntity):
|
class JellyfinSensor(JellyfinEntity, SensorEntity):
|
||||||
"""Defines a Jellyfin sensor entity."""
|
"""Defines a Jellyfin sensor entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
entity_description: JellyfinSensorEntityDescription
|
entity_description: JellyfinSensorEntityDescription
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -26,6 +26,13 @@
|
|||||||
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
"reauth_successful": "[%key:common::config_flow::abort::reauth_successful%]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"entity": {
|
||||||
|
"sensor": {
|
||||||
|
"watching": {
|
||||||
|
"name": "Active clients"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"options": {
|
"options": {
|
||||||
"step": {
|
"step": {
|
||||||
"init": {
|
"init": {
|
||||||
|
@ -4,12 +4,7 @@ from unittest.mock import MagicMock
|
|||||||
|
|
||||||
from homeassistant.components.jellyfin.const import DOMAIN
|
from homeassistant.components.jellyfin.const import DOMAIN
|
||||||
from homeassistant.components.sensor import ATTR_STATE_CLASS
|
from homeassistant.components.sensor import ATTR_STATE_CLASS
|
||||||
from homeassistant.const import (
|
from homeassistant.const import ATTR_DEVICE_CLASS, ATTR_FRIENDLY_NAME, ATTR_ICON
|
||||||
ATTR_DEVICE_CLASS,
|
|
||||||
ATTR_FRIENDLY_NAME,
|
|
||||||
ATTR_ICON,
|
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
|
||||||
)
|
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
from homeassistant.helpers import device_registry as dr, entity_registry as er
|
||||||
|
|
||||||
@ -24,13 +19,12 @@ async def test_watching(
|
|||||||
mock_jellyfin: MagicMock,
|
mock_jellyfin: MagicMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test the Jellyfin watching sensor."""
|
"""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
|
||||||
assert state.attributes.get(ATTR_DEVICE_CLASS) is None
|
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_ICON) is None
|
||||||
assert state.attributes.get(ATTR_STATE_CLASS) is None
|
assert state.attributes.get(ATTR_STATE_CLASS) is None
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Watching"
|
|
||||||
assert state.state == "3"
|
assert state.state == "3"
|
||||||
|
|
||||||
entry = entity_registry.async_get(state.entity_id)
|
entry = entity_registry.async_get(state.entity_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user