Add entity translations to Roku (#96083)
* Add entity translations to Roku * Add entity translations to Roku
This commit is contained in:
parent
406f06f0fc
commit
890efd58e0
5 changed files with 44 additions and 12 deletions
|
@ -36,27 +36,27 @@ class RokuBinarySensorEntityDescription(
|
||||||
BINARY_SENSORS: tuple[RokuBinarySensorEntityDescription, ...] = (
|
BINARY_SENSORS: tuple[RokuBinarySensorEntityDescription, ...] = (
|
||||||
RokuBinarySensorEntityDescription(
|
RokuBinarySensorEntityDescription(
|
||||||
key="headphones_connected",
|
key="headphones_connected",
|
||||||
name="Headphones connected",
|
translation_key="headphones_connected",
|
||||||
icon="mdi:headphones",
|
icon="mdi:headphones",
|
||||||
value_fn=lambda device: device.info.headphones_connected,
|
value_fn=lambda device: device.info.headphones_connected,
|
||||||
),
|
),
|
||||||
RokuBinarySensorEntityDescription(
|
RokuBinarySensorEntityDescription(
|
||||||
key="supports_airplay",
|
key="supports_airplay",
|
||||||
name="Supports AirPlay",
|
translation_key="supports_airplay",
|
||||||
icon="mdi:cast-variant",
|
icon="mdi:cast-variant",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda device: device.info.supports_airplay,
|
value_fn=lambda device: device.info.supports_airplay,
|
||||||
),
|
),
|
||||||
RokuBinarySensorEntityDescription(
|
RokuBinarySensorEntityDescription(
|
||||||
key="supports_ethernet",
|
key="supports_ethernet",
|
||||||
name="Supports ethernet",
|
translation_key="supports_ethernet",
|
||||||
icon="mdi:ethernet",
|
icon="mdi:ethernet",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda device: device.info.ethernet_support,
|
value_fn=lambda device: device.info.ethernet_support,
|
||||||
),
|
),
|
||||||
RokuBinarySensorEntityDescription(
|
RokuBinarySensorEntityDescription(
|
||||||
key="supports_find_remote",
|
key="supports_find_remote",
|
||||||
name="Supports find remote",
|
translation_key="supports_find_remote",
|
||||||
icon="mdi:remote",
|
icon="mdi:remote",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
value_fn=lambda device: device.info.supports_find_remote,
|
value_fn=lambda device: device.info.supports_find_remote,
|
||||||
|
|
|
@ -95,7 +95,7 @@ class RokuSelectEntityDescription(
|
||||||
ENTITIES: tuple[RokuSelectEntityDescription, ...] = (
|
ENTITIES: tuple[RokuSelectEntityDescription, ...] = (
|
||||||
RokuSelectEntityDescription(
|
RokuSelectEntityDescription(
|
||||||
key="application",
|
key="application",
|
||||||
name="Application",
|
translation_key="application",
|
||||||
icon="mdi:application",
|
icon="mdi:application",
|
||||||
set_fn=_launch_application,
|
set_fn=_launch_application,
|
||||||
value_fn=_get_application_name,
|
value_fn=_get_application_name,
|
||||||
|
@ -106,7 +106,7 @@ ENTITIES: tuple[RokuSelectEntityDescription, ...] = (
|
||||||
|
|
||||||
CHANNEL_ENTITY = RokuSelectEntityDescription(
|
CHANNEL_ENTITY = RokuSelectEntityDescription(
|
||||||
key="channel",
|
key="channel",
|
||||||
name="Channel",
|
translation_key="channel",
|
||||||
icon="mdi:television",
|
icon="mdi:television",
|
||||||
set_fn=_tune_channel,
|
set_fn=_tune_channel,
|
||||||
value_fn=_get_channel_name,
|
value_fn=_get_channel_name,
|
||||||
|
|
|
@ -34,14 +34,14 @@ class RokuSensorEntityDescription(
|
||||||
SENSORS: tuple[RokuSensorEntityDescription, ...] = (
|
SENSORS: tuple[RokuSensorEntityDescription, ...] = (
|
||||||
RokuSensorEntityDescription(
|
RokuSensorEntityDescription(
|
||||||
key="active_app",
|
key="active_app",
|
||||||
name="Active App",
|
translation_key="active_app",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
icon="mdi:application",
|
icon="mdi:application",
|
||||||
value_fn=lambda device: device.app.name if device.app else None,
|
value_fn=lambda device: device.app.name if device.app else None,
|
||||||
),
|
),
|
||||||
RokuSensorEntityDescription(
|
RokuSensorEntityDescription(
|
||||||
key="active_app_id",
|
key="active_app_id",
|
||||||
name="Active App ID",
|
translation_key="active_app_id",
|
||||||
entity_category=EntityCategory.DIAGNOSTIC,
|
entity_category=EntityCategory.DIAGNOSTIC,
|
||||||
icon="mdi:application-cog",
|
icon="mdi:application-cog",
|
||||||
value_fn=lambda device: device.app.app_id if device.app else None,
|
value_fn=lambda device: device.app.app_id if device.app else None,
|
||||||
|
|
|
@ -21,6 +21,38 @@
|
||||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
"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": {
|
"services": {
|
||||||
"search": {
|
"search": {
|
||||||
"name": "Search",
|
"name": "Search",
|
||||||
|
|
|
@ -34,7 +34,7 @@ async def test_roku_sensors(
|
||||||
assert entry.unique_id == f"{UPNP_SERIAL}_active_app"
|
assert entry.unique_id == f"{UPNP_SERIAL}_active_app"
|
||||||
assert entry.entity_category == EntityCategory.DIAGNOSTIC
|
assert entry.entity_category == EntityCategory.DIAGNOSTIC
|
||||||
assert state.state == "Roku"
|
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 state.attributes.get(ATTR_ICON) == "mdi:application"
|
||||||
assert ATTR_DEVICE_CLASS not in state.attributes
|
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.unique_id == f"{UPNP_SERIAL}_active_app_id"
|
||||||
assert entry.entity_category == EntityCategory.DIAGNOSTIC
|
assert entry.entity_category == EntityCategory.DIAGNOSTIC
|
||||||
assert state.state == STATE_UNKNOWN
|
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 state.attributes.get(ATTR_ICON) == "mdi:application-cog"
|
||||||
assert ATTR_DEVICE_CLASS not in state.attributes
|
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.unique_id == "YN00H5555555_active_app"
|
||||||
assert entry.entity_category == EntityCategory.DIAGNOSTIC
|
assert entry.entity_category == EntityCategory.DIAGNOSTIC
|
||||||
assert state.state == "Antenna TV"
|
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 state.attributes.get(ATTR_ICON) == "mdi:application"
|
||||||
assert ATTR_DEVICE_CLASS not in state.attributes
|
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.unique_id == "YN00H5555555_active_app_id"
|
||||||
assert entry.entity_category == EntityCategory.DIAGNOSTIC
|
assert entry.entity_category == EntityCategory.DIAGNOSTIC
|
||||||
assert state.state == "tvinput.dtv"
|
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 state.attributes.get(ATTR_ICON) == "mdi:application-cog"
|
||||||
assert ATTR_DEVICE_CLASS not in state.attributes
|
assert ATTR_DEVICE_CLASS not in state.attributes
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue