3 Commits

Author SHA1 Message Date
alexei.dolgolyov b0d98a9d45 chore: bump manifest.json version to 0.1.1
Release / release (push) Successful in 4s
2026-03-26 21:41:06 +03:00
alexei.dolgolyov d0d4958843 chore: update release notes for v0.1.1
Release / release (push) Successful in 4s
2026-03-26 21:36:27 +03:00
alexei.dolgolyov de4b7cf9b4 feat: replace script args with typed named parameters
- Change execute_script API from positional args list to named params dict
- Update service schema, API client, and constants
- Add execute_script service documentation to README
2026-03-26 21:35:51 +03:00
7 changed files with 63 additions and 56 deletions
+42
View File
@@ -103,6 +103,48 @@ Button entities for each script defined on your Media Server:
- Shutdown, restart, sleep, hibernate
- Custom scripts
### Execute Script Service
Call `remote_media_player.execute_script` to run any server-defined script with typed parameters:
```yaml
service: remote_media_player.execute_script
data:
script_name: set_brightness
params:
level: 75
monitor: primary
```
Parameters are validated against the script's schema on the server. Scripts define their parameters in `config.yaml`:
```yaml
scripts:
set_brightness:
command: "python set_brightness.py"
label: "Set Brightness"
icon: "mdi:brightness-6"
timeout: 10
parameters:
level:
type: integer
required: true
min: 0
max: 100
description: "Brightness level (0-100)"
monitor:
type: select
options: ["primary", "secondary", "all"]
default: "primary"
description: "Target monitor"
```
Supported parameter types: `string`, `integer`, `float`, `boolean`, `select`.
Parameters are passed to scripts as environment variables prefixed with `SCRIPT_PARAM_` (e.g., `SCRIPT_PARAM_LEVEL=75`, `SCRIPT_PARAM_MONITOR=primary`).
Scripts without parameters work as before — just omit `params`.
## Example Lovelace Card
```yaml
+5 -40
View File
@@ -1,32 +1,10 @@
## v0.1.0 (2026-03-26)
## v0.1.1 (2026-03-26)
Initial release of the Remote Media Player custom integration for Home Assistant.
### ⚠️ Breaking Changes
- Replace positional script `args` (list) with typed named `params` (dict) — update any automations calling `remote_media_player.execute_script` to use the new `params` format ([de4b7cf](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/de4b7cf))
### Features
- HACS-ready Home Assistant custom integration for controlling remote PC media playback ([7837714](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/7837714))
- Add turn on / turn off / toggle support for the media player entity ([e66f2f3](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/e66f2f3))
- Add automatic script reload support ([e4eeb2a](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/e4eeb2a))
- Add media browser integration for Home Assistant ([8cbe33e](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/8cbe33e))
- Add display monitor brightness and power control entities ([83153db](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/83153db))
### Bug Fixes
- Fix entity not becoming unavailable on server shutdown ([02bdcc5](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/02bdcc5))
### Performance
- Reduce WebSocket reconnect interval to 5 seconds ([959c6a4](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/959c6a4))
- Codebase audit fixes: stability and performance ([a37eb46](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/a37eb46))
---
### Development / Internal
#### Documentation
- Update README with valid repository URLs ([f2b618a](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/f2b618a))
- Replace GitHub URLs with git.dolgolyov-family.by ([b3624e6](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/b3624e6))
- Update CLAUDE.md with git push rules, versioning rules, and commit approval rules ([725fc02](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/725fc02), [b13aa86](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/b13aa86), [3798833](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/3798833))
#### CI/Build
- Add Gitea release workflow ([6c56576](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/6c56576))
- Add execute_script service documentation to README ([de4b7cf](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/de4b7cf))
---
@@ -35,19 +13,6 @@ Initial release of the Remote Media Player custom integration for Home Assistant
| Hash | Message | Author |
|------|---------|--------|
| [7837714](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/7837714) | Initial commit: HACS-ready Home Assistant integration | alexei.dolgolyov |
| [f2b618a](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/f2b618a) | Update README with valid GitHub repository URLs | alexei.dolgolyov |
| [725fc02](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/725fc02) | Update CLAUDE.md with git push rules and repo link | alexei.dolgolyov |
| [b3624e6](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/b3624e6) | Replace GitHub URLs with git.dolgolyov-family.by | alexei.dolgolyov |
| [b13aa86](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/b13aa86) | Add versioning rules to CLAUDE.md | alexei.dolgolyov |
| [3798833](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/3798833) | Update CLAUDE.md with commit/push approval rules | alexei.dolgolyov |
| [e66f2f3](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/e66f2f3) | Add turn_on/turn_off/toggle support | alexei.dolgolyov |
| [959c6a4](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/959c6a4) | Reduce WebSocket reconnect interval to 5 seconds | alexei.dolgolyov |
| [e4eeb2a](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/e4eeb2a) | Add automatic script reload support | alexei.dolgolyov |
| [8cbe33e](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/8cbe33e) | Add media browser integration for Home Assistant | alexei.dolgolyov |
| [02bdcc5](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/02bdcc5) | Fix entity not becoming unavailable on server shutdown | alexei.dolgolyov |
| [83153db](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/83153db) | Add display monitor brightness and power control entities | alexei.dolgolyov |
| [a37eb46](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/a37eb46) | Codebase audit fixes: stability and performance | alexei.dolgolyov |
| [6c56576](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/6c56576) | ci: add Gitea release workflow | alexei.dolgolyov |
| [de4b7cf](https://git.dolgolyov-family.by/alexei.dolgolyov/haos-hacs-integration-media-player/commit/de4b7cf) | feat: replace script args with typed named parameters | alexei.dolgolyov |
</details>
@@ -15,8 +15,8 @@ from homeassistant.helpers import config_validation as cv
from .api_client import MediaServerClient, MediaServerError
from .const import (
ATTR_FILE_PATH,
ATTR_SCRIPT_ARGS,
ATTR_SCRIPT_NAME,
ATTR_SCRIPT_PARAMS,
CONF_HOST,
CONF_PORT,
CONF_TOKEN,
@@ -33,9 +33,7 @@ PLATFORMS: list[Platform] = [Platform.MEDIA_PLAYER, Platform.BUTTON, Platform.NU
SERVICE_EXECUTE_SCRIPT_SCHEMA = vol.Schema(
{
vol.Required(ATTR_SCRIPT_NAME): cv.string,
vol.Optional(ATTR_SCRIPT_ARGS, default=[]): vol.All(
cv.ensure_list, [cv.string]
),
vol.Optional(ATTR_SCRIPT_PARAMS, default={}): dict,
}
)
@@ -83,10 +81,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
async def async_execute_script(call: ServiceCall) -> dict[str, Any]:
"""Execute a script on the media server."""
script_name = call.data[ATTR_SCRIPT_NAME]
script_args = call.data.get(ATTR_SCRIPT_ARGS, [])
script_params = call.data.get(ATTR_SCRIPT_PARAMS, {})
_LOGGER.debug(
"Executing script '%s' with args: %s", script_name, script_args
"Executing script '%s' with params: %s", script_name, script_params
)
# Get all clients and execute on all of them
@@ -94,7 +92,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
for entry_id, data in hass.data[DOMAIN].items():
client: MediaServerClient = data["client"]
try:
result = await client.execute_script(script_name, script_args)
result = await client.execute_script(script_name, script_params)
results[entry_id] = result
_LOGGER.info(
"Script '%s' executed on %s: success=%s",
@@ -287,19 +287,21 @@ class MediaServerClient:
return await self._request("GET", API_SCRIPTS_LIST)
async def execute_script(
self, script_name: str, args: list[str] | None = None
self,
script_name: str,
params: dict[str, str | int | float | bool] | None = None,
) -> dict[str, Any]:
"""Execute a script on the server.
Args:
script_name: Name of the script to execute
args: Optional list of arguments to pass to the script
params: Optional named parameters (validated against script schema)
Returns:
Execution result with success, exit_code, stdout, stderr
"""
endpoint = f"{API_SCRIPTS_EXECUTE}/{script_name}"
json_data = {"args": args or []}
json_data = {"params": params or {}}
return await self._request("POST", endpoint, json_data)
async def get_media_folders(self) -> dict[str, dict[str, Any]]:
@@ -47,5 +47,5 @@ SERVICE_PLAY_MEDIA_FILE = "play_media_file"
# Service attributes
ATTR_SCRIPT_NAME = "script_name"
ATTR_SCRIPT_ARGS = "args"
ATTR_SCRIPT_PARAMS = "params"
ATTR_FILE_PATH = "file_path"
@@ -8,5 +8,5 @@
"integration_type": "device",
"iot_class": "local_push",
"requirements": ["aiohttp>=3.8.0"],
"version": "1.0.0"
"version": "0.1.1"
}
@@ -9,10 +9,10 @@ execute_script:
example: "launch_spotify"
selector:
text:
args:
name: Arguments
description: Optional list of arguments to pass to the script
params:
name: Parameters
description: Optional named parameters to pass to the script (validated against script schema)
required: false
example: '["arg1", "arg2"]'
example: '{"level": 75, "monitor": "primary"}'
selector:
object: