25 Commits

Author SHA1 Message Date
alexei.dolgolyov 97c1784ad4 feat(client): v0.3.0 server compat — WS subprotocol auth, 429 retry, HTTPS, X-Request-ID
Aligns the integration with the four wire-level changes shipped in
media-server v0.3.0/0.3.1 without breaking back-compat with older
server versions or pre-existing config entries.

- WebSocket auth via Sec-WebSocket-Protocol: media-server.token.<T>
  (preferred by server v0.3.0+). The ?token= query is still sent so
  older servers and unauthenticated mode both keep working — aiohttp
  completes the handshake even when the server doesn't echo the
  subprotocol back.
- 429 Too Many Requests surfaced as MediaServerRateLimitError with
  Retry-After parsed; execute_script() sleeps min(retry_after, 30)
  and retries once before falling through to the caller.
- Optional HTTPS/WSS (CONF_USE_SSL) + optional certificate verification
  toggle (CONF_VERIFY_SSL) wired through the config flow, client, and
  WebSocket. Defaults preserve http+verified behaviour, so existing
  config entries are unchanged.
- X-Request-ID header (uuid4 hex) on every HTTP call so HA-side issues
  can be cross-referenced with the server's access/audit logs. The
  format matches the server's ^[A-Za-z0-9._-]{1,128}\$ allow-list so
  the id is preserved verbatim instead of being replaced server-side.

Bumps manifest version to 0.3.3.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 11:37:59 +03:00
alexei.dolgolyov 8e8acccbb2 chore: release v0.3.2
Release / release (push) Successful in 3s
v0.3.2
2026-05-18 13:14:03 +03:00
alexei.dolgolyov b92b69b0e8 chore: release v0.3.1
Release / release (push) Successful in 4s
v0.3.1
2026-05-18 03:18:09 +03:00
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
alexei.dolgolyov ab0585278c feat: shared DisplayCoordinator + optional API token
- Introduce DisplayCoordinator polling /api/display/monitors once per
  cycle and fan out to all per-display entities via CoordinatorEntity.
  Removes ~9x redundant requests per polling cycle that came from each
  binary_sensor/number/select/sensor/switch entity calling
  get_display_monitors() in its own async_update.
- Optimistic write-through via coordinator.apply_optimistic(...) keeps
  sibling entities in sync after slider/select writes without an extra
  network round-trip.
- Make CONF_TOKEN optional. The media server already supports running
  without auth (auth_enabled() returns False when api_tokens is empty),
  so the integration omits the Authorization header and ?token= query
  from REST/WS/album-art URLs when no token is configured. Server-side
  auth-enabled rejections still surface as invalid_auth in the UI.
- Bump manifest version to 0.3.2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 23:46:26 +03:00
alexei.dolgolyov 68e338de4e chore: release v0.3.0
Release / release (push) Successful in 3s
v0.3.0
2026-05-15 14:52:48 +03:00
alexei.dolgolyov 4156dedf5e feat(displays): per-display devices + DDC/CI capability entities
Restructure how displays are exposed in Home Assistant:

Each physical monitor is now its own HA device linked to the media-server
hub via `via_device`. The hub keeps the media_player + script buttons; per-
display devices hold the power switch, brightness slider, and the new
capability entities. This lets users place displays in their own area/room
and keeps related entities grouped together in the UI.

New platforms:
- sensor: DisplayResolutionSensor (diagnostic, from EDID)
- binary_sensor: DisplayPrimaryBinarySensor + DisplayPowerControlBinarySensor
  (both diagnostic; help users see why a power switch is or isn't created)
- select: DisplayInputSourceSelect (HDMI1/DP1/...), DisplayColorPresetSelect
  (color temperature), DisplayPictureModeSelect (VCP 0xDC scene modes)
- number: added DisplayContrastNumber alongside brightness

Other changes:
- display_device helper centralises the per-display DeviceInfo; pulls real
  manufacturer/model from EDID; device name no longer prepends the hub
  title since via_device already shows the hierarchy.
- api_client gains set_display_{contrast,input_source,color_preset,picture_mode}
  and stops forcing `?refresh=true` on every poll so HA can ride the
  server's TTL cache instead of triggering full DDC/CI probes per entity.
- select / number entities now check the server's `success` flag and re-
  sync from the actual monitor state when a write was silently rejected
  (some monitors honor reads but ignore writes for certain DDC/CI codes).

Bumps manifest.json to 0.3.0 - the device topology change is user-visible
and existing brightness/power entities migrate to per-display devices on
first reload (unique_ids are preserved).
2026-05-15 14:46:50 +03:00
alexei.dolgolyov b0d98a9d45 chore: bump manifest.json version to 0.1.1
Release / release (push) Successful in 4s
v0.1.1
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
alexei.dolgolyov f84cfec43f chore: update release notes for v0.1.0
Release / release (push) Successful in 3s
v0.1.0
2026-03-26 00:45:14 +03:00
alexei.dolgolyov 6c5657618f ci: add Gitea release workflow 2026-03-26 00:44:11 +03:00
alexei.dolgolyov a37eb46003 Codebase audit fixes: stability and performance
- Safe int conversion for position/duration (catch ValueError/TypeError)
- Hoist get_media_folders() out of browse loop (N+1 → 1 API call)
- Fix path separator detection alongside folder metadata fetch
- Increase browse pagination limit from 1000 to 5000

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 12:10:55 +03:00
alexei.dolgolyov 83153dbddd 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>
2026-02-28 12:10:48 +03:00
alexei.dolgolyov 02bdcc5d4b Fix entity not becoming unavailable on server shutdown
Trigger async_request_refresh() on WebSocket disconnect to restart
the polling loop. Without this, the coordinator's polling stays
stopped and last_update_success is never set to False.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-07 12:26:44 +03:00
alexei.dolgolyov 8cbe33eb72 Add media browser integration for Home Assistant
- Implement async_browse_media() to enable browsing media folders through HA Media Browser UI
- Add async_play_media() to handle file playback from media browser
- Add play_media_file service for automation support
- Add BROWSE_MEDIA and PLAY_MEDIA feature flags
- Implement media browser API client methods (get_media_folders, browse_folder, play_media_file)
- Fix path separator handling for cross-platform compatibility

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 22:24:08 +03:00
alexei.dolgolyov e4eeb2a97b Add automatic script reload support
Features:
- Listen for scripts_changed WebSocket messages
- Automatically reload integration when scripts change
- New on_scripts_changed callback in WebSocket client
- Seamless button entity updates without manual reload

Technical changes:
- Enhanced MediaServerWebSocket with scripts_changed handler
- Updated MediaPlayerCoordinator to trigger integration reload
- Pass config entry to coordinator for reload capability

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-06 03:53:35 +03:00
alexei.dolgolyov 959c6a4eda Reduce WebSocket reconnect interval to 5 seconds
Change DEFAULT_RECONNECT_INTERVAL from 30s to 5s for faster
reconnection after server restart.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-05 12:01:27 +03:00
alexei.dolgolyov e66f2f3b36 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>
2026-02-05 03:44:25 +03:00
alexei.dolgolyov 37988331eb Update CLAUDE.md with commit/push approval rules 2026-02-04 20:29:54 +03:00
alexei.dolgolyov b13aa86594 Add versioning rules to CLAUDE.md 2026-02-04 20:28:05 +03:00
alexei.dolgolyov b3624e66e1 Replace GitHub URLs with git.dolgolyov-family.by 2026-02-04 20:20:25 +03:00
alexei.dolgolyov 725fc02315 Update CLAUDE.md with git push rules and repo link 2026-02-04 17:44:06 +03:00
alexei.dolgolyov f2b618a223 Update README with valid GitHub repository URLs 2026-02-04 17:43:31 +03:00
alexei.dolgolyov 783771489a Initial commit: HACS-ready Home Assistant integration
Remote Media Player integration for controlling PC media playback
from Home Assistant via the Media Server API.

Features:
- Full media player controls (play, pause, stop, next, previous)
- Volume control and mute
- Seek support with smooth timeline updates
- Real-time updates via WebSocket
- Script buttons for PC control (shutdown, restart, lock, etc.)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 14:40:33 +03:00