Skip to content
This repository has been archived by the owner on Jul 1, 2023. It is now read-only.

add service to_background #66

Merged
merged 8 commits into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions custom_components/fullykiosk/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@
SERVICE_SET_CONFIG = "set_config"
SERVICE_START_APPLICATION = "start_application"
SERVICE_TO_FOREGROUND = "to_foreground"
SERVICE_TO_BACKGROUND = "to_background"

UPDATE_INTERVAL = 30
10 changes: 10 additions & 0 deletions custom_components/fullykiosk/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
SERVICE_SET_CONFIG,
SERVICE_START_APPLICATION,
SERVICE_TO_FOREGROUND,
SERVICE_TO_BACKGROUND,
)

SUPPORT_FULLYKIOSK = SUPPORT_PLAY_MEDIA | SUPPORT_VOLUME_SET
Expand Down Expand Up @@ -96,6 +97,10 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
platform.async_register_entity_service(
SERVICE_TO_FOREGROUND, {}, "async_fullykiosk_to_foreground"
)

platform.async_register_entity_service(
SERVICE_TO_BACKGROUND, {}, "async_fullykiosk_to_background"
)

async_add_entities([FullyMediaPlayer(coordinator)], False)

Expand Down Expand Up @@ -183,6 +188,11 @@ async def async_fullykiosk_start_app(self, application):
await self.coordinator.fully.startApplication(application)
await self.coordinator.async_refresh()

async def async_fullykiosk_to_background(self):
"""Bring the fullykiosk browser app back to the background."""
await self.coordinator.fully.toBackground()
await self.coordinator.async_refresh()

async def async_fullykiosk_to_foreground(self):
"""Bring the fullykiosk browser app back to the foreground."""
await self.coordinator.fully.toForeground()
Expand Down
1 change: 1 addition & 0 deletions custom_components/fullykiosk/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"batteryLevel": "Battery Level",
"screenOrientation": "Screen Orientation",
"foregroundApp": "Foreground App",
"backgroundApp": "Background App",
chpego marked this conversation as resolved.
Show resolved Hide resolved
"lastAppStart": "Last App Start",
"wifiSignalLevel": "WiFi Signal Level",
"currentPage": "Current Page",
Expand Down
14 changes: 14 additions & 0 deletions custom_components/fullykiosk/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ to_foreground:
integration: fullykiosk
domain: media_player

to_background:
name: To Background
description: Bring the Fully Kiosk Browser app to the background.
fields:
entity_id:
description: Name(s) of entities on which to bring the app to the background.
example: "media_player.amazon_fire_media_player"
name: Entity
required: true
selector:
entity:
integration: fullykiosk
domain: media_player

volume_set:
name: Set Volume
description: Set a Fully Kiosk Browser volume level.
Expand Down