From e7cc839a9689d88018cde3e284abce976b443e8e Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Tue, 27 Jun 2023 17:41:41 +0200 Subject: [PATCH] Add entity translations to Fully Kiosk (#95368) --- .../components/fully_kiosk/binary_sensor.py | 6 +- .../components/fully_kiosk/button.py | 10 +-- .../components/fully_kiosk/media_player.py | 1 + .../components/fully_kiosk/number.py | 8 +- .../components/fully_kiosk/sensor.py | 15 ++-- .../components/fully_kiosk/strings.json | 84 +++++++++++++++++++ .../components/fully_kiosk/switch.py | 10 +-- tests/components/fully_kiosk/test_button.py | 4 +- 8 files changed, 111 insertions(+), 27 deletions(-) diff --git a/homeassistant/components/fully_kiosk/binary_sensor.py b/homeassistant/components/fully_kiosk/binary_sensor.py index f7371f4caed..5eebf8a77ab 100644 --- a/homeassistant/components/fully_kiosk/binary_sensor.py +++ b/homeassistant/components/fully_kiosk/binary_sensor.py @@ -18,18 +18,18 @@ from .entity import FullyKioskEntity SENSORS: tuple[BinarySensorEntityDescription, ...] = ( BinarySensorEntityDescription( key="kioskMode", - name="Kiosk mode", + translation_key="kiosk_mode", entity_category=EntityCategory.DIAGNOSTIC, ), BinarySensorEntityDescription( key="plugged", - name="Plugged in", + translation_key="plugged_in", device_class=BinarySensorDeviceClass.PLUG, entity_category=EntityCategory.DIAGNOSTIC, ), BinarySensorEntityDescription( key="isDeviceAdmin", - name="Device admin", + translation_key="device_admin", entity_category=EntityCategory.DIAGNOSTIC, ), ) diff --git a/homeassistant/components/fully_kiosk/button.py b/homeassistant/components/fully_kiosk/button.py index 65b44262c8b..9f4d60e9574 100644 --- a/homeassistant/components/fully_kiosk/button.py +++ b/homeassistant/components/fully_kiosk/button.py @@ -39,31 +39,31 @@ class FullyButtonEntityDescription( BUTTONS: tuple[FullyButtonEntityDescription, ...] = ( FullyButtonEntityDescription( key="restartApp", - name="Restart browser", + translation_key="restart_browser", device_class=ButtonDeviceClass.RESTART, entity_category=EntityCategory.CONFIG, press_action=lambda fully: fully.restartApp(), ), FullyButtonEntityDescription( key="rebootDevice", - name="Reboot device", + translation_key="restart_device", device_class=ButtonDeviceClass.RESTART, entity_category=EntityCategory.CONFIG, press_action=lambda fully: fully.rebootDevice(), ), FullyButtonEntityDescription( key="toForeground", - name="Bring to foreground", + translation_key="to_foreground", press_action=lambda fully: fully.toForeground(), ), FullyButtonEntityDescription( key="toBackground", - name="Send to background", + translation_key="to_background", press_action=lambda fully: fully.toBackground(), ), FullyButtonEntityDescription( key="loadStartUrl", - name="Load start URL", + translation_key="load_start_url", press_action=lambda fully: fully.loadStartUrl(), ), ) diff --git a/homeassistant/components/fully_kiosk/media_player.py b/homeassistant/components/fully_kiosk/media_player.py index 8c73d47dd74..0984d6a220f 100644 --- a/homeassistant/components/fully_kiosk/media_player.py +++ b/homeassistant/components/fully_kiosk/media_player.py @@ -33,6 +33,7 @@ async def async_setup_entry( class FullyMediaPlayer(FullyKioskEntity, MediaPlayerEntity): """Representation of a Fully Kiosk Browser media player entity.""" + _attr_name = None _attr_supported_features = MEDIA_SUPPORT_FULLYKIOSK _attr_assumed_state = True diff --git a/homeassistant/components/fully_kiosk/number.py b/homeassistant/components/fully_kiosk/number.py index 11f5bd27452..298a58e2a11 100644 --- a/homeassistant/components/fully_kiosk/number.py +++ b/homeassistant/components/fully_kiosk/number.py @@ -16,7 +16,7 @@ from .entity import FullyKioskEntity ENTITY_TYPES: tuple[NumberEntityDescription, ...] = ( NumberEntityDescription( key="timeToScreensaverV2", - name="Screensaver timer", + translation_key="screensaver_time", native_max_value=9999, native_step=1, native_min_value=0, @@ -25,7 +25,7 @@ ENTITY_TYPES: tuple[NumberEntityDescription, ...] = ( ), NumberEntityDescription( key="screensaverBrightness", - name="Screensaver brightness", + translation_key="screensaver_brightness", native_max_value=255, native_step=1, native_min_value=0, @@ -33,7 +33,7 @@ ENTITY_TYPES: tuple[NumberEntityDescription, ...] = ( ), NumberEntityDescription( key="timeToScreenOffV2", - name="Screen off timer", + translation_key="screen_off_time", native_max_value=9999, native_step=1, native_min_value=0, @@ -42,7 +42,7 @@ ENTITY_TYPES: tuple[NumberEntityDescription, ...] = ( ), NumberEntityDescription( key="screenBrightness", - name="Screen brightness", + translation_key="screen_brightness", native_max_value=255, native_step=1, native_min_value=0, diff --git a/homeassistant/components/fully_kiosk/sensor.py b/homeassistant/components/fully_kiosk/sensor.py index eed14f24674..dd775e7d55a 100644 --- a/homeassistant/components/fully_kiosk/sensor.py +++ b/homeassistant/components/fully_kiosk/sensor.py @@ -51,7 +51,6 @@ class FullySensorEntityDescription(SensorEntityDescription): SENSORS: tuple[FullySensorEntityDescription, ...] = ( FullySensorEntityDescription( key="batteryLevel", - name="Battery", device_class=SensorDeviceClass.BATTERY, native_unit_of_measurement=PERCENTAGE, state_class=SensorStateClass.MEASUREMENT, @@ -59,23 +58,23 @@ SENSORS: tuple[FullySensorEntityDescription, ...] = ( ), FullySensorEntityDescription( key="currentPage", - name="Current page", + translation_key="current_page", entity_category=EntityCategory.DIAGNOSTIC, state_fn=truncate_url, ), FullySensorEntityDescription( key="screenOrientation", - name="Screen orientation", + translation_key="screen_orientation", entity_category=EntityCategory.DIAGNOSTIC, ), FullySensorEntityDescription( key="foregroundApp", - name="Foreground app", + translation_key="foreground_app", entity_category=EntityCategory.DIAGNOSTIC, ), FullySensorEntityDescription( key="internalStorageFreeSpace", - name="Internal storage free space", + translation_key="internal_storage_free_space", entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, @@ -84,7 +83,7 @@ SENSORS: tuple[FullySensorEntityDescription, ...] = ( ), FullySensorEntityDescription( key="internalStorageTotalSpace", - name="Internal storage total space", + translation_key="internal_storage_total_space", entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, @@ -93,7 +92,7 @@ SENSORS: tuple[FullySensorEntityDescription, ...] = ( ), FullySensorEntityDescription( key="ramFreeMemory", - name="Free memory", + translation_key="ram_free_memory", entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, @@ -102,7 +101,7 @@ SENSORS: tuple[FullySensorEntityDescription, ...] = ( ), FullySensorEntityDescription( key="ramTotalMemory", - name="Total memory", + translation_key="ram_total_memory", entity_category=EntityCategory.DIAGNOSTIC, native_unit_of_measurement=UnitOfInformation.MEGABYTES, device_class=SensorDeviceClass.DATA_SIZE, diff --git a/homeassistant/components/fully_kiosk/strings.json b/homeassistant/components/fully_kiosk/strings.json index a6442085683..c10b6162859 100644 --- a/homeassistant/components/fully_kiosk/strings.json +++ b/homeassistant/components/fully_kiosk/strings.json @@ -21,5 +21,89 @@ "abort": { "already_configured": "[%key:common::config_flow::abort::already_configured_account%]" } + }, + "entity": { + "binary_sensor": { + "kiosk_mode": { + "name": "Kiosk mode" + }, + "plugged_in": { + "name": "Plugged in" + }, + "device_admin": { + "name": "Device admin" + } + }, + "button": { + "restart_browser": { + "name": "Restart browser" + }, + "restart_device": { + "name": "Restart device" + }, + "to_foreground": { + "name": "Bring to foreground" + }, + "to_background": { + "name": "Send to background" + }, + "load_start_url": { + "name": "Load start URL" + } + }, + "number": { + "screensaver_time": { + "name": "Screensaver timer" + }, + "screensaver_brightness": { + "name": "Screensaver brightness" + }, + "screen_off_time": { + "name": "Screen off timer" + }, + "screen_brightness": { + "name": "Screen brightness" + } + }, + "sensor": { + "current_page": { + "name": "Current page" + }, + "screen_orientation": { + "name": "Screen orientation" + }, + "foreground_app": { + "name": "Foreground app" + }, + "internal_storage_total_space": { + "name": "Internal storage total space" + }, + "internal_storage_free_space": { + "name": "Internal storage free space" + }, + "ram_free_memory": { + "name": "Free memory" + }, + "ram_total_memory": { + "name": "Total memory" + } + }, + "switch": { + "screensaver": { + "name": "Screensaver" + }, + "maintenance": { + "name": "Maintenance mode" + }, + "kiosk": { + "name": "Kiosk lock" + }, + "motion_detection": { + "name": "Motion detection" + }, + "screen_on": { + "name": "Screen" + } + } } } diff --git a/homeassistant/components/fully_kiosk/switch.py b/homeassistant/components/fully_kiosk/switch.py index 1bd2a10fd21..500e154abd8 100644 --- a/homeassistant/components/fully_kiosk/switch.py +++ b/homeassistant/components/fully_kiosk/switch.py @@ -37,14 +37,14 @@ class FullySwitchEntityDescription( SWITCHES: tuple[FullySwitchEntityDescription, ...] = ( FullySwitchEntityDescription( key="screensaver", - name="Screensaver", + translation_key="screensaver", on_action=lambda fully: fully.startScreensaver(), off_action=lambda fully: fully.stopScreensaver(), is_on_fn=lambda data: data.get("isInScreensaver"), ), FullySwitchEntityDescription( key="maintenance", - name="Maintenance mode", + translation_key="maintenance", entity_category=EntityCategory.CONFIG, on_action=lambda fully: fully.enableLockedMode(), off_action=lambda fully: fully.disableLockedMode(), @@ -52,7 +52,7 @@ SWITCHES: tuple[FullySwitchEntityDescription, ...] = ( ), FullySwitchEntityDescription( key="kiosk", - name="Kiosk lock", + translation_key="kiosk", entity_category=EntityCategory.CONFIG, on_action=lambda fully: fully.lockKiosk(), off_action=lambda fully: fully.unlockKiosk(), @@ -60,7 +60,7 @@ SWITCHES: tuple[FullySwitchEntityDescription, ...] = ( ), FullySwitchEntityDescription( key="motion-detection", - name="Motion detection", + translation_key="motion_detection", entity_category=EntityCategory.CONFIG, on_action=lambda fully: fully.enableMotionDetection(), off_action=lambda fully: fully.disableMotionDetection(), @@ -68,7 +68,7 @@ SWITCHES: tuple[FullySwitchEntityDescription, ...] = ( ), FullySwitchEntityDescription( key="screenOn", - name="Screen", + translation_key="screen_on", on_action=lambda fully: fully.screenOn(), off_action=lambda fully: fully.screenOff(), is_on_fn=lambda data: data.get("screenOn"), diff --git a/tests/components/fully_kiosk/test_button.py b/tests/components/fully_kiosk/test_button.py index 7e780e3fec3..fee39be302e 100644 --- a/tests/components/fully_kiosk/test_button.py +++ b/tests/components/fully_kiosk/test_button.py @@ -30,13 +30,13 @@ async def test_buttons( ) assert len(mock_fully_kiosk.restartApp.mock_calls) == 1 - entry = entity_registry.async_get("button.amazon_fire_reboot_device") + entry = entity_registry.async_get("button.amazon_fire_restart_device") assert entry assert entry.unique_id == "abcdef-123456-rebootDevice" await hass.services.async_call( button.DOMAIN, button.SERVICE_PRESS, - {ATTR_ENTITY_ID: "button.amazon_fire_reboot_device"}, + {ATTR_ENTITY_ID: "button.amazon_fire_restart_device"}, blocking=True, ) assert len(mock_fully_kiosk.rebootDevice.mock_calls) == 1