Files
haos-hacs-integration-media…/custom_components/remote_media_player/const.py
T
alexei.dolgolyov 9d277276b8 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>
2026-05-18 03:13:23 +03:00

61 lines
1.9 KiB
Python

"""Constants for the Remote Media Player integration."""
DOMAIN = "remote_media_player"
# Configuration keys
CONF_HOST = "host"
CONF_PORT = "port"
CONF_TOKEN = "token"
CONF_POLL_INTERVAL = "poll_interval"
CONF_NAME = "name"
CONF_USE_WEBSOCKET = "use_websocket"
# Default values
DEFAULT_PORT = 8765
DEFAULT_POLL_INTERVAL = 5
DEFAULT_NAME = "Remote Media Player"
DEFAULT_USE_WEBSOCKET = True
DEFAULT_RECONNECT_INTERVAL = 5
# Displays change rarely (brightness/contrast/input source via physical buttons
# or external automations), so a slow shared poll is plenty. The previous
# per-entity polling produced ~9 calls every 30 s for a single monitor.
DEFAULT_DISPLAY_POLL_INTERVAL = 30
# API endpoints
API_HEALTH = "/api/health"
API_STATUS = "/api/media/status"
API_PLAY = "/api/media/play"
API_PAUSE = "/api/media/pause"
API_STOP = "/api/media/stop"
API_NEXT = "/api/media/next"
API_PREVIOUS = "/api/media/previous"
API_VOLUME = "/api/media/volume"
API_MUTE = "/api/media/mute"
API_SEEK = "/api/media/seek"
API_TURN_ON = "/api/media/turn_on"
API_TURN_OFF = "/api/media/turn_off"
API_TOGGLE = "/api/media/toggle"
API_SCRIPTS_LIST = "/api/scripts/list"
API_SCRIPTS_EXECUTE = "/api/scripts/execute"
API_WEBSOCKET = "/api/media/ws"
API_BROWSER_FOLDERS = "/api/browser/folders"
API_BROWSER_BROWSE = "/api/browser/browse"
API_BROWSER_PLAY = "/api/browser/play"
API_FOREGROUND = "/api/foreground"
API_DISPLAY_MONITORS = "/api/display/monitors"
API_DISPLAY_BRIGHTNESS = "/api/display/brightness"
API_DISPLAY_POWER = "/api/display/power"
API_DISPLAY_CONTRAST = "/api/display/contrast"
API_DISPLAY_INPUT_SOURCE = "/api/display/input_source"
API_DISPLAY_COLOR_PRESET = "/api/display/color_preset"
API_DISPLAY_PICTURE_MODE = "/api/display/picture_mode"
# Service names
SERVICE_EXECUTE_SCRIPT = "execute_script"
SERVICE_PLAY_MEDIA_FILE = "play_media_file"
# Service attributes
ATTR_SCRIPT_NAME = "script_name"
ATTR_SCRIPT_PARAMS = "params"
ATTR_FILE_PATH = "file_path"