Add icon translations to Sonarr (#112233)
This commit is contained in:
parent
ffcb06beb9
commit
f368457544
3 changed files with 24 additions and 13 deletions
24
homeassistant/components/sonarr/icons.json
Normal file
24
homeassistant/components/sonarr/icons.json
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"entity": {
|
||||||
|
"sensor": {
|
||||||
|
"commands": {
|
||||||
|
"default": "mdi:code-braces"
|
||||||
|
},
|
||||||
|
"diskspace": {
|
||||||
|
"default": "mdi:harddisk"
|
||||||
|
},
|
||||||
|
"queue": {
|
||||||
|
"default": "mdi:download"
|
||||||
|
},
|
||||||
|
"series": {
|
||||||
|
"default": "mdi:television"
|
||||||
|
},
|
||||||
|
"upcoming": {
|
||||||
|
"default": "mdi:television"
|
||||||
|
},
|
||||||
|
"wanted": {
|
||||||
|
"default": "mdi:television"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -89,7 +89,6 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
"commands": SonarrSensorEntityDescription[list[Command]](
|
"commands": SonarrSensorEntityDescription[list[Command]](
|
||||||
key="commands",
|
key="commands",
|
||||||
translation_key="commands",
|
translation_key="commands",
|
||||||
icon="mdi:code-braces",
|
|
||||||
native_unit_of_measurement="Commands",
|
native_unit_of_measurement="Commands",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
value_fn=len,
|
value_fn=len,
|
||||||
|
@ -98,7 +97,6 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
"diskspace": SonarrSensorEntityDescription[list[Diskspace]](
|
"diskspace": SonarrSensorEntityDescription[list[Diskspace]](
|
||||||
key="diskspace",
|
key="diskspace",
|
||||||
translation_key="diskspace",
|
translation_key="diskspace",
|
||||||
icon="mdi:harddisk",
|
|
||||||
native_unit_of_measurement=UnitOfInformation.GIGABYTES,
|
native_unit_of_measurement=UnitOfInformation.GIGABYTES,
|
||||||
device_class=SensorDeviceClass.DATA_SIZE,
|
device_class=SensorDeviceClass.DATA_SIZE,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
|
@ -108,7 +106,6 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
"queue": SonarrSensorEntityDescription[SonarrQueue](
|
"queue": SonarrSensorEntityDescription[SonarrQueue](
|
||||||
key="queue",
|
key="queue",
|
||||||
translation_key="queue",
|
translation_key="queue",
|
||||||
icon="mdi:download",
|
|
||||||
native_unit_of_measurement="Episodes",
|
native_unit_of_measurement="Episodes",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
value_fn=lambda data: data.totalRecords,
|
value_fn=lambda data: data.totalRecords,
|
||||||
|
@ -117,7 +114,6 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
"series": SonarrSensorEntityDescription[list[SonarrSeries]](
|
"series": SonarrSensorEntityDescription[list[SonarrSeries]](
|
||||||
key="series",
|
key="series",
|
||||||
translation_key="series",
|
translation_key="series",
|
||||||
icon="mdi:television",
|
|
||||||
native_unit_of_measurement="Series",
|
native_unit_of_measurement="Series",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
value_fn=len,
|
value_fn=len,
|
||||||
|
@ -131,7 +127,6 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
"upcoming": SonarrSensorEntityDescription[list[SonarrCalendar]](
|
"upcoming": SonarrSensorEntityDescription[list[SonarrCalendar]](
|
||||||
key="upcoming",
|
key="upcoming",
|
||||||
translation_key="upcoming",
|
translation_key="upcoming",
|
||||||
icon="mdi:television",
|
|
||||||
native_unit_of_measurement="Episodes",
|
native_unit_of_measurement="Episodes",
|
||||||
value_fn=len,
|
value_fn=len,
|
||||||
attributes_fn=lambda data: {
|
attributes_fn=lambda data: {
|
||||||
|
@ -141,7 +136,6 @@ SENSOR_TYPES: dict[str, SonarrSensorEntityDescription[Any]] = {
|
||||||
"wanted": SonarrSensorEntityDescription[SonarrWantedMissing](
|
"wanted": SonarrSensorEntityDescription[SonarrWantedMissing](
|
||||||
key="wanted",
|
key="wanted",
|
||||||
translation_key="wanted",
|
translation_key="wanted",
|
||||||
icon="mdi:television",
|
|
||||||
native_unit_of_measurement="Episodes",
|
native_unit_of_measurement="Episodes",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
value_fn=lambda data: data.totalRecords,
|
value_fn=lambda data: data.totalRecords,
|
||||||
|
|
|
@ -8,7 +8,6 @@ import pytest
|
||||||
|
|
||||||
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ICON,
|
|
||||||
ATTR_UNIT_OF_MEASUREMENT,
|
ATTR_UNIT_OF_MEASUREMENT,
|
||||||
STATE_UNAVAILABLE,
|
STATE_UNAVAILABLE,
|
||||||
UnitOfInformation,
|
UnitOfInformation,
|
||||||
|
@ -50,41 +49,35 @@ async def test_sensors(
|
||||||
|
|
||||||
state = hass.states.get("sensor.sonarr_commands")
|
state = hass.states.get("sensor.sonarr_commands")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:code-braces"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Commands"
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Commands"
|
||||||
assert state.state == "2"
|
assert state.state == "2"
|
||||||
|
|
||||||
state = hass.states.get("sensor.sonarr_disk_space")
|
state = hass.states.get("sensor.sonarr_disk_space")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:harddisk"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfInformation.GIGABYTES
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfInformation.GIGABYTES
|
||||||
assert state.attributes.get("C:\\") == "263.10/465.42GB (56.53%)"
|
assert state.attributes.get("C:\\") == "263.10/465.42GB (56.53%)"
|
||||||
assert state.state == "263.10"
|
assert state.state == "263.10"
|
||||||
|
|
||||||
state = hass.states.get("sensor.sonarr_queue")
|
state = hass.states.get("sensor.sonarr_queue")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:download"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Episodes"
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Episodes"
|
||||||
assert state.attributes.get("The Andy Griffith Show S01E01") == "100.00%"
|
assert state.attributes.get("The Andy Griffith Show S01E01") == "100.00%"
|
||||||
assert state.state == "1"
|
assert state.state == "1"
|
||||||
|
|
||||||
state = hass.states.get("sensor.sonarr_shows")
|
state = hass.states.get("sensor.sonarr_shows")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:television"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Series"
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Series"
|
||||||
assert state.attributes.get("The Andy Griffith Show") == "0/0 Episodes"
|
assert state.attributes.get("The Andy Griffith Show") == "0/0 Episodes"
|
||||||
assert state.state == "1"
|
assert state.state == "1"
|
||||||
|
|
||||||
state = hass.states.get("sensor.sonarr_upcoming")
|
state = hass.states.get("sensor.sonarr_upcoming")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:television"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Episodes"
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Episodes"
|
||||||
assert state.attributes.get("Bob's Burgers") == "S04E11"
|
assert state.attributes.get("Bob's Burgers") == "S04E11"
|
||||||
assert state.state == "1"
|
assert state.state == "1"
|
||||||
|
|
||||||
state = hass.states.get("sensor.sonarr_wanted")
|
state = hass.states.get("sensor.sonarr_wanted")
|
||||||
assert state
|
assert state
|
||||||
assert state.attributes.get(ATTR_ICON) == "mdi:television"
|
|
||||||
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Episodes"
|
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == "Episodes"
|
||||||
assert state.attributes.get("Bob's Burgers S04E11") == "2014-01-26T17:30:00-08:00"
|
assert state.attributes.get("Bob's Burgers S04E11") == "2014-01-26T17:30:00-08:00"
|
||||||
assert (
|
assert (
|
||||||
|
|
Loading…
Add table
Reference in a new issue