fixed not being able to pass data trough service data
This commit is contained in:
parent
55083f4bd8
commit
99ca6d9d0d
@ -57,12 +57,17 @@ change_monitors_config:
|
|||||||
name: Change monitors config
|
name: Change monitors config
|
||||||
description: Change monitors config.
|
description: Change monitors config.
|
||||||
fields:
|
fields:
|
||||||
|
entity_id:
|
||||||
|
name: Entity ID
|
||||||
|
description: Entity ID of the device to change monitors config.
|
||||||
|
required: true
|
||||||
|
selector:
|
||||||
|
entity:
|
||||||
|
integration: easy_computer_manage
|
||||||
|
domain: switch
|
||||||
monitors_config:
|
monitors_config:
|
||||||
name: Monitors config
|
name: Monitors config
|
||||||
description: Monitors config.
|
description: Monitors config.
|
||||||
required: true
|
required: true
|
||||||
selector:
|
selector:
|
||||||
text:
|
object:
|
||||||
target:
|
|
||||||
device:
|
|
||||||
integration: easy_computer_manage
|
|
@ -22,7 +22,7 @@ from homeassistant.const import (
|
|||||||
CONF_NAME,
|
CONF_NAME,
|
||||||
CONF_PASSWORD,
|
CONF_PASSWORD,
|
||||||
CONF_PORT,
|
CONF_PORT,
|
||||||
CONF_USERNAME,
|
CONF_USERNAME, CONF_ENTITY_ID,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers import (
|
from homeassistant.helpers import (
|
||||||
@ -58,6 +58,12 @@ PLATFORM_SCHEMA = PARENT_PLATFORM_SCHEMA.extend(
|
|||||||
vol.Optional(CONF_PORT, default=22): cv.string,
|
vol.Optional(CONF_PORT, default=22): cv.string,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
SERVICE_CHANGE_MONITORS_CONFIG_SCHEMA = vol.Schema(
|
||||||
|
{
|
||||||
|
vol.Required(CONF_ENTITY_ID): cv.entity_id,
|
||||||
|
vol.Required("monitors_config"): dict,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
@ -121,7 +127,7 @@ async def async_setup_entry(
|
|||||||
)
|
)
|
||||||
platform.async_register_entity_service(
|
platform.async_register_entity_service(
|
||||||
SERVICE_CHANGE_MONITORS_CONFIG,
|
SERVICE_CHANGE_MONITORS_CONFIG,
|
||||||
{},
|
SERVICE_CHANGE_MONITORS_CONFIG_SCHEMA,
|
||||||
SERVICE_CHANGE_MONITORS_CONFIG,
|
SERVICE_CHANGE_MONITORS_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -255,9 +261,10 @@ class ComputerSwitch(SwitchEntity):
|
|||||||
else:
|
else:
|
||||||
utils.restart_system(self._connection)
|
utils.restart_system(self._connection)
|
||||||
|
|
||||||
def change_monitors_config(self, yaml_config: str) -> None:
|
def change_monitors_config(self, **kwargs) -> None:
|
||||||
"""Change the monitors configuration using a YAML config file."""
|
"""Change the monitors configuration using a YAML config file."""
|
||||||
utils.change_monitors_config(self._connection, yaml_config)
|
if kwargs["monitors_config"] is not None:
|
||||||
|
utils.change_monitors_config(self._connection, kwargs["monitors_config"])
|
||||||
|
|
||||||
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."""
|
||||||
|
@ -206,7 +206,7 @@ def restart_to_windows_from_linux(connection: Connection):
|
|||||||
connection.host)
|
connection.host)
|
||||||
|
|
||||||
|
|
||||||
def change_monitors_config(connection: Connection, monitors_config: str):
|
def change_monitors_config(connection: Connection, monitors_config: dict):
|
||||||
"""From a YAML config, changes the monitors configuration on the host, only works on Linux and Gnome (for now)."""
|
"""From a YAML config, changes the monitors configuration on the host, only works on Linux and Gnome (for now)."""
|
||||||
# TODO: Add support for Windows
|
# TODO: Add support for Windows
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user