add restart to linux from windows service
This commit is contained in:
parent
3752673d92
commit
5b027759cf
@ -3,6 +3,7 @@
|
||||
DOMAIN = "easy_computer_manage"
|
||||
SERVICE_SEND_MAGIC_PACKET = "send_magic_packet"
|
||||
SERVICE_RESTART_TO_WINDOWS_FROM_LINUX = "restart_to_windows_from_linux"
|
||||
SERVICE_RESTART_TO_LINUX_FROM_WINDOWS = "restart_to_linux_from_windows"
|
||||
SERVICE_PUT_COMPUTER_TO_SLEEP = "put_computer_to_sleep"
|
||||
SERVICE_START_COMPUTER_TO_WINDOWS = "start_computer_to_windows"
|
||||
RESTART_COMPUTER = "restart_computer"
|
||||
|
@ -29,6 +29,12 @@ restart_to_windows_from_linux:
|
||||
target:
|
||||
device:
|
||||
integration: easy_computer_manage
|
||||
restart_to_linux_from_windows:
|
||||
name: Restart to Linux from Windows
|
||||
description: Restart the computer to Linux when running Windows.
|
||||
target:
|
||||
device:
|
||||
integration: easy_computer_manage
|
||||
start_computer_to_windows:
|
||||
name: Start computer to Windows
|
||||
description: Start the computer directly Windows (boots to Linux, set grub reboot, then boots to Windows).
|
||||
|
@ -35,7 +35,7 @@ from paramiko.ssh_exception import AuthenticationException
|
||||
|
||||
from . import utils
|
||||
from .const import SERVICE_RESTART_TO_WINDOWS_FROM_LINUX, SERVICE_PUT_COMPUTER_TO_SLEEP, \
|
||||
SERVICE_START_COMPUTER_TO_WINDOWS, RESTART_COMPUTER
|
||||
SERVICE_START_COMPUTER_TO_WINDOWS, RESTART_COMPUTER, SERVICE_RESTART_TO_LINUX_FROM_WINDOWS
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
@ -98,6 +98,11 @@ async def async_setup_entry(
|
||||
{},
|
||||
SERVICE_RESTART_TO_WINDOWS_FROM_LINUX,
|
||||
)
|
||||
platform.async_register_entity_service(
|
||||
SERVICE_RESTART_TO_LINUX_FROM_WINDOWS,
|
||||
{},
|
||||
SERVICE_RESTART_TO_LINUX_FROM_WINDOWS,
|
||||
)
|
||||
platform.async_register_entity_service(
|
||||
SERVICE_PUT_COMPUTER_TO_SLEEP,
|
||||
{},
|
||||
@ -192,6 +197,15 @@ class ComputerSwitch(SwitchEntity):
|
||||
else:
|
||||
_LOGGER.error("This computer is not running a dualboot system.")
|
||||
|
||||
def restart_to_linux_from_windows(self) -> None:
|
||||
"""Restart the computer to Linux from a running Windows by setting grub-reboot and restarting."""
|
||||
|
||||
if self._dualboot:
|
||||
# TODO: check for default grub entry and adapt accordingly
|
||||
utils.restart_system(self._connection)
|
||||
else:
|
||||
_LOGGER.error("This computer is not running a dualboot system.")
|
||||
|
||||
def put_computer_to_sleep(self) -> None:
|
||||
"""Put the computer to sleep using appropriate sleep command based on running OS and/or distro."""
|
||||
utils.sleep_system(self._connection)
|
||||
|
Loading…
Reference in New Issue
Block a user