Add display monitor brightness and power control entities

- Add NUMBER platform for monitor brightness (0-100)
- Add SWITCH platform for monitor power on/off
- Add display API client methods (get_display_monitors, set_display_brightness, set_display_power)
- Add display API constants

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-28 12:10:48 +03:00
parent 02bdcc5d4b
commit 83153dbddd
5 changed files with 278 additions and 1 deletions

View File

@@ -30,6 +30,9 @@ from .const import (
API_BROWSER_FOLDERS,
API_BROWSER_BROWSE,
API_BROWSER_PLAY,
API_DISPLAY_MONITORS,
API_DISPLAY_BRIGHTNESS,
API_DISPLAY_POWER,
)
_LOGGER = logging.getLogger(__name__)
@@ -342,6 +345,42 @@ class MediaServerClient:
"""
return await self._request("POST", API_BROWSER_PLAY, {"path": file_path})
async def get_display_monitors(self) -> list[dict[str, Any]]:
"""Get list of connected monitors with brightness and power info.
Returns:
List of monitor dicts with id, name, brightness, power_supported, power_on, resolution
"""
return await self._request("GET", f"{API_DISPLAY_MONITORS}?refresh=true")
async def set_display_brightness(self, monitor_id: int, brightness: int) -> dict[str, Any]:
"""Set brightness for a specific monitor.
Args:
monitor_id: Monitor index
brightness: Brightness level (0-100)
Returns:
Response data with success status
"""
return await self._request(
"POST", f"{API_DISPLAY_BRIGHTNESS}/{monitor_id}", {"brightness": brightness}
)
async def set_display_power(self, monitor_id: int, on: bool) -> dict[str, Any]:
"""Set power state for a specific monitor.
Args:
monitor_id: Monitor index
on: True to turn on, False to turn off
Returns:
Response data with success status
"""
return await self._request(
"POST", f"{API_DISPLAY_POWER}/{monitor_id}", {"on": on}
)
class MediaServerWebSocket:
"""WebSocket client for real-time media status updates."""