feat(foreground): foreground process sensors + translation key migration

Adds Home Assistant entities for the foreground-process feature shipped
in the media server, plus migrates existing display entities to use HA
translation keys (strings.json / translations/*) so per-language UI text
flows through the standard locale mechanism.

Foreground entities (all share one HA "Foreground" device linked to the
hub via via_device):
- sensor.foreground_process — process name as state + full payload
  (pid, exec path, window title, fullscreen flag, monitor, geometry,
  is_browser, browser_page_title, browser_url, error) as attributes
- sensor.window_title, sensor.pid, sensor.foreground_monitor,
  sensor.process_started (TIMESTAMP device class)
- binary_sensor.fullscreen, binary_sensor.minimized

Data flow:
- ForegroundCoordinator polls GET /api/foreground every 5s (HTTP fallback)
- media_player's WebSocket receiver forwards `foreground` /
  `foreground_update` push frames into the coordinator via
  apply_websocket_snapshot, so sensors update in near-real-time when WS
  is connected and fall back to polling otherwise

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-05-18 03:13:23 +03:00
parent ab0585278c
commit 9d277276b8
14 changed files with 463 additions and 32 deletions
@@ -172,6 +172,7 @@ class MediaPlayerCoordinator(DataUpdateCoordinator[dict[str, Any]]):
on_status_update=self._handle_ws_status_update,
on_disconnect=self._handle_ws_disconnect,
on_scripts_changed=self._handle_ws_scripts_changed,
on_foreground_update=self._handle_ws_foreground_update,
)
if await self._ws_client.connect():
@@ -206,6 +207,19 @@ class MediaPlayerCoordinator(DataUpdateCoordinator[dict[str, Any]]):
# Schedule reconnect attempt
self._schedule_reconnect()
@callback
def _handle_ws_foreground_update(self, data: dict[str, Any]) -> None:
"""Forward a foreground WS push into the shared foreground coordinator."""
if not self._entry:
return
try:
store = self.hass.data[DOMAIN][self._entry.entry_id]
except KeyError:
return
coordinator = store.get("foreground_coordinator")
if coordinator is not None:
coordinator.apply_websocket_snapshot(data)
@callback
def _handle_ws_scripts_changed(self) -> None:
"""Handle scripts changed notification from WebSocket."""