Add turn_on/turn_off/toggle support

- Add API_TURN_ON, API_TURN_OFF, API_TOGGLE constants
- Add turn_on(), turn_off(), toggle() methods to MediaServerClient
- Implement async_turn_on, async_turn_off, async_toggle in media player
- Add TURN_ON and TURN_OFF to supported features
- Update README with turn on/off/toggle documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 03:44:25 +03:00
parent 37988331eb
commit e66f2f3b36
4 changed files with 79 additions and 0 deletions

View File

@@ -22,6 +22,9 @@ from .const import (
API_VOLUME,
API_MUTE,
API_SEEK,
API_TURN_ON,
API_TURN_OFF,
API_TOGGLE,
API_SCRIPTS_LIST,
API_SCRIPTS_EXECUTE,
)
@@ -245,6 +248,30 @@ class MediaServerClient:
"""
return await self._request("POST", API_SEEK, {"position": position})
async def turn_on(self) -> dict[str, Any]:
"""Send turn on command.
Returns:
Response data
"""
return await self._request("POST", API_TURN_ON)
async def turn_off(self) -> dict[str, Any]:
"""Send turn off command.
Returns:
Response data
"""
return await self._request("POST", API_TURN_OFF)
async def toggle(self) -> dict[str, Any]:
"""Send toggle command.
Returns:
Response data
"""
return await self._request("POST", API_TOGGLE)
async def list_scripts(self) -> list[dict[str, Any]]:
"""List available scripts on the server.