Skip to content

feat(tv): Home Assistant route (run a script/scene/media_player via REST) - #95

Draft
nextestudios wants to merge 5 commits into
lippdev:mainfrom
nextestudios:feat/tv-home-assistant
Draft

nextestudios wants to merge 5 commits into
lippdev:mainfrom
nextestudios:feat/tv-home-assistant

Conversation

@nextestudios

Copy link
Copy Markdown
Contributor

Depends on #93 (TV control plumbing). This branch sits on top of it; only the last commit, feat(tv): Home Assistant route, is new here. Independent of #94 (LG). I'll rebase once #93 is merged.

Summary

Third route for #75: Home Assistant. It already reaches almost any TV (CEC from a Pi, LG, Samsung, Sony, Roku…), so Console Mode just runs an entity there on start and, optionally, on restore.

  • Settings → TV → Home Assistant: base URL, long-lived access token (PasswordBox), entity to run on start (e.g. script.tv_to_pc) and an optional one for restore.
  • POST /api/services/<domain>/<service> with {"entity_id": …} and a bearer token: script/scene → turn_on, automation → trigger, button/input_button → press, anything else → turn_on. On restore: the restore entity if set, otherwise turn_off on a stateful start entity (media_player, switch…); a script/scene start entity with no restore entity does nothing (logged).
  • Clear messages for a missing URL/token/entity, unreachable server, 401/403 (bad token) and 400/404 (unknown entity).
  • The token is stored DPAPI-encrypted for the current Windows user (dpapi: prefix in config.json), via System.Security.Cryptography.ProtectedData (new package reference, Microsoft, MIT). Plain values pass through so hand-edited configs still work.
  • Pure mapping/URL/body logic in HomeAssistantApi.cs, linked into the tests.
  • Strings in pt-BR / en-US / es-ES; guide section (en + pt-BR), README bullet, docs/TESTING.md §3e, changelog under [Unreleased].

Validation

  • New HomeAssistantApiTests (service per domain, restore rules, entity validation, URL building with/without scheme and trailing slash, request body).
  • Written on macOS: the app build and dotnet test are left to CI.
  • Manual checks in docs/TESTING.md §3e.

🤖 Generated with Claude Code

nextestudios and others added 5 commits September 26, 2026 19:57
… / Android TV)

Settings → TV: console mode wakes the TV and switches it to the PC's HDMI
input before the display flow, and can put it in standby after the restore.
First provider: Google TV / Android TV through ADB (port 5555), with a small
in-process ADB client (auth with this PC's RSA key, shell key events), so
nothing has to be installed on the PC. Optional Wake-on-LAN for TVs that drop
off the network in standby, and a custom input command for TVs that ignore
the HDMI key codes. A TV that doesn't answer is only logged.

Refs lippdev#75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…EST)

Runs the chosen entity through POST /api/services/<domain>/<service> with a
long-lived token: scripts/scenes turn_on, automations trigger, buttons
press, stateful entities turn_on (and turn_off on restore when no restore
entity is set). The token is stored DPAPI-encrypted for the Windows user.

Refs lippdev#75

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant