Add entity translations to Fully Kiosk (#95368)

This commit is contained in:
Joost Lekkerkerker 2023-06-27 17:41:41 +02:00 committed by GitHub
parent df65fa3899
commit e7cc839a96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 111 additions and 27 deletions

View file

@ -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,
),
)

View file

@ -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(),
),
)

View file

@ -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

View file

@ -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,

View file

@ -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,

View file

@ -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"
}
}
}
}

View file

@ -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"),

View file

@ -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