Add entity translations to Roku (#96083)

* Add entity translations to Roku

* Add entity translations to Roku
pull/98826/head
Joost Lekkerkerker 2023-08-22 16:59:56 +02:00 committed by GitHub
parent 406f06f0fc
commit 890efd58e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 12 deletions

View File

@ -36,27 +36,27 @@ class RokuBinarySensorEntityDescription(
BINARY_SENSORS: tuple[RokuBinarySensorEntityDescription, ...] = (
RokuBinarySensorEntityDescription(
key="headphones_connected",
name="Headphones connected",
translation_key="headphones_connected",
icon="mdi:headphones",
value_fn=lambda device: device.info.headphones_connected,
),
RokuBinarySensorEntityDescription(
key="supports_airplay",
name="Supports AirPlay",
translation_key="supports_airplay",
icon="mdi:cast-variant",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.info.supports_airplay,
),
RokuBinarySensorEntityDescription(
key="supports_ethernet",
name="Supports ethernet",
translation_key="supports_ethernet",
icon="mdi:ethernet",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.info.ethernet_support,
),
RokuBinarySensorEntityDescription(
key="supports_find_remote",
name="Supports find remote",
translation_key="supports_find_remote",
icon="mdi:remote",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.info.supports_find_remote,

View File

@ -95,7 +95,7 @@ class RokuSelectEntityDescription(
ENTITIES: tuple[RokuSelectEntityDescription, ...] = (
RokuSelectEntityDescription(
key="application",
name="Application",
translation_key="application",
icon="mdi:application",
set_fn=_launch_application,
value_fn=_get_application_name,
@ -106,7 +106,7 @@ ENTITIES: tuple[RokuSelectEntityDescription, ...] = (
CHANNEL_ENTITY = RokuSelectEntityDescription(
key="channel",
name="Channel",
translation_key="channel",
icon="mdi:television",
set_fn=_tune_channel,
value_fn=_get_channel_name,

View File

@ -34,14 +34,14 @@ class RokuSensorEntityDescription(
SENSORS: tuple[RokuSensorEntityDescription, ...] = (
RokuSensorEntityDescription(
key="active_app",
name="Active App",
translation_key="active_app",
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:application",
value_fn=lambda device: device.app.name if device.app else None,
),
RokuSensorEntityDescription(
key="active_app_id",
name="Active App ID",
translation_key="active_app_id",
entity_category=EntityCategory.DIAGNOSTIC,
icon="mdi:application-cog",
value_fn=lambda device: device.app.app_id if device.app else None,

View File

@ -21,6 +21,38 @@
"unknown": "[%key:common::config_flow::error::unknown%]"
}
},
"entity": {
"binary_sensor": {
"headphones_connected": {
"name": "Headphones connected"
},
"supports_airplay": {
"name": "Supports AirPlay"
},
"supports_ethernet": {
"name": "Supports ethernet"
},
"supports_find_remote": {
"name": "Supports find remote"
}
},
"select": {
"application": {
"name": "Application"
},
"channel": {
"name": "Channel"
}
},
"sensor": {
"active_app": {
"name": "Active app"
},
"active_app_id": {
"name": "Active app ID"
}
}
},
"services": {
"search": {
"name": "Search",

View File

@ -34,7 +34,7 @@ async def test_roku_sensors(
assert entry.unique_id == f"{UPNP_SERIAL}_active_app"
assert entry.entity_category == EntityCategory.DIAGNOSTIC
assert state.state == "Roku"
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Roku 3 Active App"
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Roku 3 Active app"
assert state.attributes.get(ATTR_ICON) == "mdi:application"
assert ATTR_DEVICE_CLASS not in state.attributes
@ -45,7 +45,7 @@ async def test_roku_sensors(
assert entry.unique_id == f"{UPNP_SERIAL}_active_app_id"
assert entry.entity_category == EntityCategory.DIAGNOSTIC
assert state.state == STATE_UNKNOWN
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Roku 3 Active App ID"
assert state.attributes.get(ATTR_FRIENDLY_NAME) == "My Roku 3 Active app ID"
assert state.attributes.get(ATTR_ICON) == "mdi:application-cog"
assert ATTR_DEVICE_CLASS not in state.attributes
@ -83,7 +83,7 @@ async def test_rokutv_sensors(
assert entry.unique_id == "YN00H5555555_active_app"
assert entry.entity_category == EntityCategory.DIAGNOSTIC
assert state.state == "Antenna TV"
assert state.attributes.get(ATTR_FRIENDLY_NAME) == '58" Onn Roku TV Active App'
assert state.attributes.get(ATTR_FRIENDLY_NAME) == '58" Onn Roku TV Active app'
assert state.attributes.get(ATTR_ICON) == "mdi:application"
assert ATTR_DEVICE_CLASS not in state.attributes
@ -94,7 +94,7 @@ async def test_rokutv_sensors(
assert entry.unique_id == "YN00H5555555_active_app_id"
assert entry.entity_category == EntityCategory.DIAGNOSTIC
assert state.state == "tvinput.dtv"
assert state.attributes.get(ATTR_FRIENDLY_NAME) == '58" Onn Roku TV Active App ID'
assert state.attributes.get(ATTR_FRIENDLY_NAME) == '58" Onn Roku TV Active app ID'
assert state.attributes.get(ATTR_ICON) == "mdi:application-cog"
assert ATTR_DEVICE_CLASS not in state.attributes