Skip to content

feat(tv): turn the TV on and switch input over the network (Google TV / Android TV) - #93

Draft
nextestudios wants to merge 3 commits into
lippdev:mainfrom
nextestudios:feat/tv-control
Draft

nextestudios wants to merge 3 commits into
lippdev:mainfrom
nextestudios:feat/tv-control

Conversation

@nextestudios

Copy link
Copy Markdown
Contributor

Summary

First step for #75: console mode turns the TV on and switches it to the PC's HDMI input, and can put it in standby after the restore. This PR adds the plumbing plus the Google TV / Android TV route (TCL, Sony, Hisense, Philips…), which needs no extra hardware and nothing installed on the PC.

  • Settings → TV (new section): route (Don't control it / Google TV / Android TV (network)), TV IP, optional MAC for Wake-on-LAN, PC's HDMI input, an advanced input command, "Put the TV in standby on restore" (off by default) and Test now.
  • Engine: ConsoleEngine.Start calls TvControlService.TurnOn first, so the TV is up before the fresh screen read / EnsureActive wait; Stop optionally calls TurnOff after the desk is back. Both are bounded (30 s / 15 s) and never throw: a TV that doesn't answer is only logged, and the existing "game screen did not turn on" path does the rest.
  • Android TV: a small in-process ADB client (Services/Tv/AdbClient.cs) on port 5555: CNXN, AUTH with this PC's RSA-2048 key (kept in the data folder as adbkey.pem, so the TV asks "Allow debugging?" once), then shell:input keyevent WAKEUP → TV_INPUT_HDMI_n (SLEEP for standby). No adb.exe to ship. If the TV is unreachable and a MAC is set, it sends Wake-on-LAN and retries for 20 s. "Wireless debugging" (TLS pairing) is detected and explained instead of hanging.
  • ITvController / TvControlService.Create are the extension point for the other routes in the issue (LG webOS, Home Assistant, USB-CEC), which I'll send as separate PRs on top of this one.
  • Pure logic in AdbProtocol.cs / WakeOnLan.cs (framing, checksum/magic, token signature, Android's RSAPublicKey layout with n0inv/rr, endpoint parsing, HDMI key codes, MAC parsing, magic packet), linked into the test project.
  • Strings in pt-BR / en-US / es-ES; guide section "TV control" (en + pt-BR), README bullet, docs/TESTING.md §3c, changelog under [Unreleased].

Validation

  • New TvControlTests (ADB framing and header validation, signature verifies as a SHA-1 digest, public key layout checked against BigInteger math, endpoint/HDMI mapping, MAC parsing, magic packet).
  • Written on macOS: the app build and dotnet test are left to CI.
  • Hardware checks in docs/TESTING.md §3c; to be run on a TCL Google TV.

🤖 Generated with Claude Code

nextestudios and others added 3 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>
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