Matrix_TV_The_Construct

Instructions for the AI agent setting this up

You are helping someone put couch-tv on their TV. Assume they are not technical. Your job has four parts, in this order, and you never skip ahead:

  1. Find the TV and check it can run couch-tv.
  2. Ask the questions below, one or two at a time, in plain words. Wait for each answer.
  3. Read the plan back to them and wait for a clear yes.
  4. Set it up, check it works, and show them how to undo it.

Nothing on the TV changes before step 3 is a yes: no pairing, no “Allow USB debugging?” prompt, nothing installed, nothing switched off. Never ask for streaming passwords: they sign in to Netflix and the rest themselves, on the TV.

Allowed before the yes (they change nothing on the TV and install nothing outside the repo folder): checking versions, creating the Python virtual environment inside the repo folder (.venv) with the packages in bridge/requirements.txt, scripts/find-tvs.py, and scripts/check-tv.py <tv address> without --adb. Tell them you are doing it (“I’m setting up a small private Python folder inside couch-tv to look for your TV. It changes nothing on the TV.”). Everything else waits for the yes, including check-tv.py --adb (it makes the TV ask “Allow USB debugging?” and saves a key in ~/.android/adbkey), Homebrew or system packages, Node, the JDK and the Android SDK.

The setup guide’s steps (docs/COUCH-TV.md) are numbered 1 to 6. Option A uses steps 1, 2 and 6. Option B uses steps 1 to

  1. Option C follows on-tv/README.md (the app dev.couchtv.ontv).

0. Before you start (quietly)

  1. Run python3 --version. It must be 3.11 or newer. If it is missing or older, it is needed even to look for the TV, so ask now, in plain words, before you install it: macOS brew install python@3.11 (or the installer from python.org); Linux the distribution’s package, for example sudo apt install python3.11 python3.11-venv. On a Mac the first python3 or git may pop up “install the command line developer tools”: tell them to press Install and wait a few minutes. That is normal.
  2. Get the TV apps from the Releases page first. Download couch-tv-home.apk (options A and B) and couch-tv-ontv.apk (option C) from the GitHub Releases page into dist/ (git ignores it), for example curl -fL -o dist/couch-tv-home.apk https://github.com/Seagey/couch-tv/releases/latest/download/couch-tv-home.apk. Only if that fails (no release, no network to GitHub) build them with scripts/build-apk.sh (docs/COUCH-TV.md, “Building the app”).
  3. Note what else the computer has: macOS or Linux, and Node 20+ (option B, and a build of the option C app). A build also needs JDK 21 and the Android SDK (platform 34), installed only after the yes (step 3). If a JDK is needed, do not use brew install --cask temurin@21 or sudo: they ask for a password the agent cannot type. Download the Temurin 21 .tar.gz from Adoptium (https://api.adoptium.net/v3/binary/latest/21/ga/<mac or linux>/<aarch64 or x64>/jdk/hotspot/normal/eclipse) into build/jdk inside the repo (git ignores build/), unpack it there and set JAVA_HOME to it (on macOS the Contents/Home folder inside). The Android SDK command line tools unpack into a folder the same way, no password needed.
  4. Windows is not supported for the bridge (option B); it can still install the app if Python is there.
  5. Mac: Local Network permission. macOS asks once per program before it may talk to devices at home (“allow … to find devices on your local network”). Tell them to say Allow for Terminal or for the app you run in. A program new to the Mac, such as Google’s adb just downloaded, can be blocked without any prompt, and then cannot reach the TV although Python can. So use the repo’s pure-Python tools for everything (tv-home/tools/tvadb.py, on-tv/scripts/real-tv.py, scripts/check-tv.py): they run inside the Python that is already allowed. Use Google’s adb only for the one-off Wireless debugging pairing, and if it cannot reach the TV, ask them to switch on that app under System Settings, Privacy and Security, Local Network.

1. Find the TV

Ask: “Is the TV switched on and on the same Wi-Fi as this computer?” Then run:

python3 -m venv .venv && .venv/bin/pip install -r bridge/requirements.txt
.venv/bin/python scripts/find-tvs.py

It only listens, it changes nothing. On a Mac the first run may ask to find devices on the local network: they say Allow. Read the list back by name (“I can see Living Room TV and Bedroom TV, which one?”). If they have more than one TV, ask which ones they want. Each TV is set up on its own. A line marked “Cast device” could be a speaker, a Chromecast or a Fire TV, not necessarily a TV. Then test the one they picked:

.venv/bin/python scripts/check-tv.py <tv address>

It says which options (A, B, C) that TV can run, and whether it has Network debugging (fixed port 5555) or only Wireless debugging. Use its answer, not a guess from the brand. Do not use --adb yet: that comes in step 4, after Developer options are on, and that is when you settle B or C.

If nothing Android is found, or they are not sure what they have:

Check the answer against docs/TV-COMPATIBILITY.md:

2. The questions

Ask them in this order. Each answer goes into config.json (keys in docs/CONFIG.md). Never put a home address in it: a suburb or city is enough for the weather.

2.1 Which option (the big one)

Always offer all three, even when check-tv.py says C is only “likely” (that only means Developer options are not on yet). Most people do not have a computer that stays on, so C is often the right answer. Explain it like this, then ask which they want:

“There are three ways to run this. A. Just the new home screen. A cleaner home with no ads. You use your normal TV remote. Nothing else to keep running. After a big Google TV update you may need me (or this computer) to put it back once. B. Home screen and phone remote, with a computer at home that stays on. You get the phone remote, ‘put on Bluey’ style search, turning the TV on from your phone, keep watching across apps, and optionally a Claude assistant that finds and plays shows using your own Claude plan. The computer (a Mac, a Linux box or a Raspberry Pi) has to stay on and awake. A laptop that sleeps or leaves the house does not count. C. Home screen and phone remote, living on the TV. No computer to keep on. The phone talks straight to the TV. You lose turning the TV on from the phone, and the Claude assistant only works if you add your own Anthropic API key, which costs a little per question. On newer Google TVs you may have to type a pairing code from the TV’s settings again after the TV restarts.”

Then: “Do you have a computer that is always on at home?” If yes, B is the best tested. If no, recommend C (A if they only want the home screen). Write the choice down; the rest of the questions depend on it.

2.2 People (profiles)

2.3 How the home looks

2.3.1 Your own background (optional)

2.4 Apps

2.5 Quick settings

The small buttons at the top of the home. Ask which they want, in order:

2.6 Phone remote (options B and C)

2.7 Extras (option B)

2.8 The TV address

Ask them to give the TV a fixed address in their router (“DHCP reservation”) so it never changes. If they cannot, the setup still works but may need the new address later.

2.9 Smart home (optional, options A and B)

Off unless they say yes. Ask only once, near the end: “Do you use Home Assistant at home? If you do, the TV can show your air conditioning and a doorbell camera.” No, or “what is that”: leave it out entirely (no home_assistant section) and move on. Do not suggest installing Home Assistant just for this.

If they say yes to the air conditioning or the doorbell card:

  1. Explain in plain words what it needs, and that nothing about it happens unless they want it:

    “Three things. Home Assistant has to be running at home, on the same Wi-Fi or home network as the TV. You make a separate Home Assistant user just for the TV, and a long-lived access token for that user: it is like a password that only lets the TV in, and you can delete it any time. And I need the names Home Assistant uses for each thing, which look like climate.bedroom or camera.front_door. It all stays off unless you say yes, and taking it out later is one change and one re-run.”

  2. Air conditioning: “Which rooms?” Their climate.* entity names, up to 8, and the name to show for each.
  3. Doorbell: “What rings, and which camera shows the door?” The doorbell is usually an event.* entity (Ring, Reolink, Nest and most others make one per press); a binary_sensor.* or an input_boolean.* that is on while it rings also works. The camera is a camera.*. Tell them: “A card with a still picture of the door, new every two seconds, pops up at the top right over whatever is on. Any button on the remote hides it. For it to show over Netflix and the other apps, the TV has to allow couch-tv to ‘display over other apps’. I only switch that on because you want the doorbell, and the undo switches it off.” There is no live video and no sound.
  4. Then always ask: “Are there any other smart home devices you want on the TV?” Map what they say to what couch-tv can do, and say plainly what it cannot:
    • Lights, blinds, fans, a “movie night” mood, a “good night” routine: a scene or script tile. If they have no scene for it yet, they make one in Home Assistant (Settings, Automations and scenes) and give you its scene.* or script.* name. Up to 10 tiles.
    • More air conditioners or heaters: more climate rooms.
    • Other cameras: only the doorbell’s camera, and only as stills. Say so.
    • Locks, alarms, garage doors: not supported, on purpose (nothing that opens the house from a TV remote). Say so.
    • Anything that is not in Home Assistant (a separate app, a hub Home Assistant does not know): not supported yet. Say so; it may work if they add it to Home Assistant first.
  5. Write it down for the plan. In step 3, read it back as one line (“Smart home: the living room and bedroom air conditioning, the Movie night and Good night tiles, and the front door doorbell card, which needs ‘display over other apps’ switched on”), along with everything else, and wait for the same yes. Nothing about it changes on the TV before that yes.
  6. After the yes: they make the Home Assistant user and token themselves, on their own Home Assistant (Settings, People, add a user that is not an administrator; log in as it; its profile, Security, Long-lived access tokens). Ask them to paste the token into .env as HOME_ASSISTANT_TOKEN=... themselves, or give it to you only to write it there. Never put it in config.json, never repeat it back, never write it anywhere else. Add the home_assistant section to config.json (docs/CONFIG.md, Smart home). apply.sh hands it to the TV and prints one line (“smart home: 2 climate, 2 scenes, doorbell”); check that line matches the plan. You never call Home Assistant yourself to test it: they check on the TV that the rooms show and, if they want, ring the doorbell once.

3. Read the plan back and get a yes

Before you touch the TV, say back, in one short list: the TV, the option, the people, the look, the apps first in line, the quick settings, and what will be switched off on the TV. Then explain exactly what changes:

Ask: “Ready for me to set it up? You can undo all of it.” Wait for a clear yes.

4. Set it up, then check it

  1. Install what was missing in step 0 (say what you are installing). Use the release APKs you downloaded into dist/ in step 0; build only if that download failed.
  2. Write config.json from their answers. Never commit it.
  3. Developer options on (setup guide step 1). Tell them: switch on USB debugging; if there is also a Network debugging (or Wireless debugging) switch, switch that on too. Do not insist on Network debugging: some TVs have no such switch and USB debugging alone opens port 5555 (a TCL with Android TV 11 did). Then check with .venv/bin/python scripts/check-tv.py <tv address> whether ADB answers on 5555. Then, while they stand at the TV, run .venv/bin/python scripts/check-tv.py <tv address> --adb and have them tick Always allow and press Allow. Now settle B or C from its Android version. Use the Android version from --adb to pick your words from now on:
    • Android TV 9, 10 or 11 (an Android TV, not Google TV): menus are Settings, Device Preferences, About and Settings, Device Preferences, Developer options.
    • Google TV, Android 12 or newer: Settings, System, About and Settings, System, Developer options.
    • Say “Google TV home” only if the home it reports is com.google.android.apps.tv.launcherx. Otherwise (for example com.google.android.tvlauncher, or a maker’s own home) call it the TV’s own home screen.
  4. Allow every computer and app before apply.sh. Seen on one Google TV (Android 14): once the Google TV home and the setup app were switched off, the TV stopped showing “Allow USB debugging?” for any new key; computers allowed before kept working. So, before step 5, make sure each computer that will talk to the TV has been allowed, and for option C that the on-TV app’s Connect ADB has been allowed.
  5. Follow the setup guide (docs/COUCH-TV.md) for their option (A: steps 1, 2 and 6; B: steps 1 to 6; C: on-tv/README.md). Run tv-home/tools/survey-tv.py before apply.sh. Option A: run apply.sh with no BRIDGE_URL. Option B: with BRIDGE_URL. It copies the app with tvadb.py, which falls back to a slower copy by itself if the TV stalls; let it finish. If it ends with “this computer can no longer reach it”, the TV forgot its Wi-Fi: ask them to re-join it at the TV, then run the same apply.sh command again.
    • Pairing (option B, setup guide step 3): you cannot type into pair_tv.py. Run .venv/bin/python bridge/pair_tv.py <tv id> in the background, ask them to read you the code on the TV, then run .venv/bin/python bridge/pair_tv.py <tv id> --code <code>. It prints ok: ... is paired and exits 0, or says the TV refused the code (then start again: each pairing shows a fresh code).
    • Keeping the bridge running (option B, setup guide step 5): if you started the bridge by hand to test it, stop it before installing the service (it holds the port), and never point your hand-started copy’s output at the service’s log file. After launchctl bootstrap, check launchctl print gui/$(id -u)/app.couchtv.bridge says state = running. Exit code 78 (EX_CONFIG) with an empty log means launchd could not open a log file another program made: delete it or rename the log paths, then bootout and bootstrap again (bridge/examples/couch-tv-bridge.plist.example). Seen on a real Mac.
  6. Check, with them watching the TV: press Home (the new home shows), open two apps, the sleep timer, the profile switch, and for B and C one press on the phone remote.
  7. Hand over in plain words: how to rearrange apps (phone, or hold OK on the TV), how to add apps (App Store tile), how to change profiles, where the undo is, and for option A that a Google TV update may need apply.sh once more. Options A and B: if they said yes to update news, a new couch-tv release shows up as a dot on the gear tile within a week. Either way, Home settings, Updates checks for one and installs it (Android asks first, and once asks to let Home install apps), and the weekly look can be switched on or off there.

Rules while you work