added steam big picture service
This commit is contained in:
parent
b010429981
commit
9a23a6712a
32
HOWTO.md
32
HOWTO.md
@ -85,6 +85,10 @@ Restart the computer.
|
|||||||
|
|
||||||
Change monitors config.
|
Change monitors config.
|
||||||
|
|
||||||
|
### Target
|
||||||
|
|
||||||
|
- **Device Integration:** easy_computer_manage
|
||||||
|
|
||||||
### Fields
|
### Fields
|
||||||
|
|
||||||
- `monitors_config`
|
- `monitors_config`
|
||||||
@ -103,11 +107,27 @@ Change monitors config.
|
|||||||
transform: normal
|
transform: normal
|
||||||
scale: 2
|
scale: 2
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
- `entity_id`
|
|
||||||
- **Name:** Entity ID
|
|
||||||
- **Description:** Entity ID of the device to change the monitors config.
|
## `steam_big_picture`
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
Start/stop Steam in Big Picture mode or go back to Steam desktop UI.
|
||||||
|
|
||||||
|
### Target
|
||||||
|
|
||||||
|
- **Device Integration:** easy_computer_manage
|
||||||
|
|
||||||
|
### Fields
|
||||||
|
|
||||||
|
- `action`
|
||||||
|
- **Name:** Action
|
||||||
|
- **Description:** Action to perform.
|
||||||
- **Required:** true
|
- **Required:** true
|
||||||
- **Example:** "switch.my_computer"
|
- **Selector:** select
|
||||||
- **Device Integration:** easy_computer_manage
|
- **Options:**
|
||||||
|
- **start**: Start Steam in Big Picture mode.
|
||||||
|
- **stop**: Stop Steam in Big Picture mode.
|
||||||
|
- **exit**: Go back to Steam desktop UI.
|
@ -8,3 +8,4 @@ SERVICE_PUT_COMPUTER_TO_SLEEP = "put_computer_to_sleep"
|
|||||||
SERVICE_START_COMPUTER_TO_WINDOWS = "start_computer_to_windows"
|
SERVICE_START_COMPUTER_TO_WINDOWS = "start_computer_to_windows"
|
||||||
SERVICE_RESTART_COMPUTER = "restart_computer"
|
SERVICE_RESTART_COMPUTER = "restart_computer"
|
||||||
SERVICE_CHANGE_MONITORS_CONFIG = "change_monitors_config"
|
SERVICE_CHANGE_MONITORS_CONFIG = "change_monitors_config"
|
||||||
|
SERVICE_STEAM_BIG_PICTURE = "steam_big_picture"
|
||||||
|
@ -74,4 +74,26 @@ change_monitors_config:
|
|||||||
transform: normal
|
transform: normal
|
||||||
scale: 2
|
scale: 2
|
||||||
selector:
|
selector:
|
||||||
object:
|
object:
|
||||||
|
steam_big_picture:
|
||||||
|
name: Start/stop Steam Big Picture
|
||||||
|
description: Start/stop Steam Big Picture.
|
||||||
|
target:
|
||||||
|
entity:
|
||||||
|
integration: easy_computer_manager
|
||||||
|
domain: switch
|
||||||
|
fields:
|
||||||
|
action:
|
||||||
|
name: Action
|
||||||
|
description: Choose whether to start/stop Steam Big Picture or go back to the desktop Steam UI.
|
||||||
|
required: true
|
||||||
|
example: "start"
|
||||||
|
selector:
|
||||||
|
select:
|
||||||
|
options:
|
||||||
|
- label: Start
|
||||||
|
value: start
|
||||||
|
- label: Stop
|
||||||
|
value: stop
|
||||||
|
- label: Exit and go back to the desktop Steam UI
|
||||||
|
value: exit
|
@ -37,7 +37,7 @@ from paramiko.ssh_exception import AuthenticationException
|
|||||||
from . import utils
|
from . import utils
|
||||||
from .const import SERVICE_RESTART_TO_WINDOWS_FROM_LINUX, SERVICE_PUT_COMPUTER_TO_SLEEP, \
|
from .const import SERVICE_RESTART_TO_WINDOWS_FROM_LINUX, SERVICE_PUT_COMPUTER_TO_SLEEP, \
|
||||||
SERVICE_START_COMPUTER_TO_WINDOWS, SERVICE_RESTART_COMPUTER, SERVICE_RESTART_TO_LINUX_FROM_WINDOWS, \
|
SERVICE_START_COMPUTER_TO_WINDOWS, SERVICE_RESTART_COMPUTER, SERVICE_RESTART_TO_LINUX_FROM_WINDOWS, \
|
||||||
SERVICE_CHANGE_MONITORS_CONFIG
|
SERVICE_CHANGE_MONITORS_CONFIG, SERVICE_STEAM_BIG_PICTURE
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -95,31 +95,20 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
|
|
||||||
platform = entity_platform.async_get_current_platform()
|
platform = entity_platform.async_get_current_platform()
|
||||||
platform.async_register_entity_service(
|
|
||||||
SERVICE_RESTART_TO_WINDOWS_FROM_LINUX,
|
services = [SERVICE_RESTART_TO_WINDOWS_FROM_LINUX,
|
||||||
{},
|
SERVICE_RESTART_TO_LINUX_FROM_WINDOWS,
|
||||||
SERVICE_RESTART_TO_WINDOWS_FROM_LINUX,
|
SERVICE_PUT_COMPUTER_TO_SLEEP,
|
||||||
)
|
SERVICE_START_COMPUTER_TO_WINDOWS,
|
||||||
platform.async_register_entity_service(
|
SERVICE_RESTART_COMPUTER]
|
||||||
SERVICE_RESTART_TO_LINUX_FROM_WINDOWS,
|
|
||||||
{},
|
for service in services:
|
||||||
SERVICE_RESTART_TO_LINUX_FROM_WINDOWS,
|
platform.async_register_entity_service(
|
||||||
)
|
service,
|
||||||
platform.async_register_entity_service(
|
{},
|
||||||
SERVICE_PUT_COMPUTER_TO_SLEEP,
|
service,
|
||||||
{},
|
)
|
||||||
SERVICE_PUT_COMPUTER_TO_SLEEP,
|
|
||||||
)
|
|
||||||
platform.async_register_entity_service(
|
|
||||||
SERVICE_START_COMPUTER_TO_WINDOWS,
|
|
||||||
{},
|
|
||||||
SERVICE_START_COMPUTER_TO_WINDOWS,
|
|
||||||
)
|
|
||||||
platform.async_register_entity_service(
|
|
||||||
SERVICE_RESTART_COMPUTER,
|
|
||||||
{},
|
|
||||||
SERVICE_RESTART_COMPUTER,
|
|
||||||
)
|
|
||||||
platform.async_register_entity_service(
|
platform.async_register_entity_service(
|
||||||
SERVICE_CHANGE_MONITORS_CONFIG,
|
SERVICE_CHANGE_MONITORS_CONFIG,
|
||||||
make_entity_service_schema(
|
make_entity_service_schema(
|
||||||
@ -127,6 +116,13 @@ async def async_setup_entry(
|
|||||||
),
|
),
|
||||||
SERVICE_CHANGE_MONITORS_CONFIG,
|
SERVICE_CHANGE_MONITORS_CONFIG,
|
||||||
)
|
)
|
||||||
|
platform.async_register_entity_service(
|
||||||
|
SERVICE_STEAM_BIG_PICTURE,
|
||||||
|
make_entity_service_schema(
|
||||||
|
{vol.Required("action"): str}
|
||||||
|
),
|
||||||
|
SERVICE_STEAM_BIG_PICTURE,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ComputerSwitch(SwitchEntity):
|
class ComputerSwitch(SwitchEntity):
|
||||||
@ -265,6 +261,14 @@ class ComputerSwitch(SwitchEntity):
|
|||||||
else:
|
else:
|
||||||
raise HomeAssistantError("The monitors config is empty.")
|
raise HomeAssistantError("The monitors config is empty.")
|
||||||
|
|
||||||
|
def steam_big_picture(self, action: str) -> None:
|
||||||
|
"""Controls Steam Big Picture mode."""
|
||||||
|
|
||||||
|
if action is not None:
|
||||||
|
utils.steam_big_picture(self._connection, action)
|
||||||
|
else:
|
||||||
|
raise HomeAssistantError("You must specify an action.")
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Ping the computer to see if it is online and update the state."""
|
"""Ping the computer to see if it is online and update the state."""
|
||||||
ping_cmd = [
|
ping_cmd = [
|
||||||
|
@ -317,3 +317,36 @@ def parse_gnome_monitor_config(output):
|
|||||||
monitors.append(current_monitor)
|
monitors.append(current_monitor)
|
||||||
|
|
||||||
return monitors
|
return monitors
|
||||||
|
|
||||||
|
|
||||||
|
def steam_big_picture(connection: Connection, action: str):
|
||||||
|
"""Controls Steam in Big Picture mode on the host."""
|
||||||
|
|
||||||
|
_LOGGER.debug(f"Running Steam Big Picture action {action} on system running at {connection.host}.")
|
||||||
|
|
||||||
|
result = None
|
||||||
|
match action:
|
||||||
|
case "start":
|
||||||
|
if is_unix_system(connection):
|
||||||
|
result = connection.run("export WAYLAND_DISPLAY=wayland-0; export DISPLAY=:0; steam -bigpicture &")
|
||||||
|
else:
|
||||||
|
result = connection.run("start steam://open/bigpicture")
|
||||||
|
case "stop":
|
||||||
|
if is_unix_system(connection):
|
||||||
|
result = connection.run("export WAYLAND_DISPLAY=wayland-0; export DISPLAY=:0; steam -shutdown &")
|
||||||
|
else:
|
||||||
|
# TODO: check for different Steam install paths
|
||||||
|
result = connection.run("C:\\Program Files (x86)\\Steam\\steam.exe -shutdown")
|
||||||
|
case "exit":
|
||||||
|
if is_unix_system(connection):
|
||||||
|
# TODO: find a way to exit Steam Big Picture
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
# TODO: need to test (thx @MasterHidra https://www.reddit.com/r/Steam/comments/5c9l20/comment/k5fmb3k)
|
||||||
|
result = connection.run("nircmd win close title \"Steam Big Picture Mode\"")
|
||||||
|
case _:
|
||||||
|
raise HomeAssistantError(
|
||||||
|
f"Invalid action {action} for Steam Big Picture on system running at {connection.host}.")
|
||||||
|
|
||||||
|
if result is None or result.return_code != 0:
|
||||||
|
raise HomeAssistantError(f"Could not {action} Steam Big Picture on system running at {connection.host}.")
|
||||||
|
Loading…
Reference in New Issue
Block a user