Files
pdtv26/docs/setup.md
T
dckc cf503ac247
check / check (push) Canceled after 0s
docs: DIY electronics pics; parts move to setup
The box's photo goes up top, by the paragraph that introduces it. The
parts list, with the workbench photo, moves to the setup guide's What
you need; the README's Make your own tells how mine was made. The
machine that runs speech and the brain is named for its roles, speech
server and agent host, not "home server".

Generated-by: Claude Opus 5.5
2026-12-02 20:52:51 -06:00

84 lines
5.3 KiB
Markdown

# Setting up the agent at the TV
The steps below are in the order they depend on each other. Each `make` target says more with `make help`.
## What you need
<a href="https://archive.org/details/dckc-ultimate-diy-tv-remote/PXL_20261123_033039525.jpg">
<img src="https://ia601808.us.archive.org/8/items/dckc-ultimate-diy-tv-remote/PXL_20261123_033039525_thumb.jpg" alt="electronics workbench with raspberry pi pico and IR transceiver"/>
</a>
- **The box:** a Raspberry Pi 3B with a [Google AIY Voice Kit v1](https://aiyprojects.withgoogle.com/voice-v1/) (speaker, two mics, the button).
- **The IR emitter:** a Raspberry Pi Pico H with an IR transceiver ([wiring](../ir-pico/wiring.md)), on a USB cord from the box, aimed at the equipment.
- **The camera:** an RTSP camera on the LAN, aimed at the TV.
- **A speech server and agent host:** any Linux machine with Nix and systemd, on whenever the box is in use. It runs speech and the brain, and builds the box's image. x86_64 with AVX2 is plenty: whisper.cpp's base.en model transcribes an 11 s clip in about 2 s.
- **A private network** that the box, the speech server, and the agent host can all join: Tailscale, by default.
- **An afternoon.**
## 1. Make a repository for your household
A private git repository of your own holds what's yours: the names you choose, and later who the brain serves. None of that belongs in pdtv26. Its `flake.nix`:
```nix
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
inputs.pdtv26 = {
url = "git+https://git.inference.coop/dckc/pdtv26";
inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, pdtv26, ... }: {
nixosConfigurations.pimote = pdtv26.lib.mkBox {
name = "pimote"; # the box's host name on your network
server = "den-pc"; # the speech server and agent host's name
wifi = "MyNetwork"; # your Wi-Fi network's name (SSID), spelled exactly
admin = "pat"; # who looks after the box, and logs in to deploy
sshKeys = [ "ssh-ed25519 AAAA... pat@laptop" ];
};
# The box's SD card image, built on x86_64 Linux.
packages.x86_64-linux.sd-image = self.nixosConfigurations.pimote.config.system.build.sdImage;
};
}
```
Ports have defaults, and the box finds the IR emitter by its USB IDs. Anything else about the box's system goes in `modules = [ ./household.nix ]`, alongside: a status page (`pdtv26.box.statusUrl`), another Wi-Fi network, another private network (`pdtv26.box.network`), or no camera (`pdtv26.box.look.enable = false`).
## 2. Set up the speech server
[Install Nix](https://nixos.org/download/) if it isn't there yet. Clone pdtv26, then:
1. `sudo make -C speech install`: the speech server, its models (about 200 MB), its key, and its systemd unit.
2. `sudo make -C status install BOX=pimote`: the status page, if you want one.
The brain comes after the box, in step 5, since it needs the box's keys.
## 3. Make the box's SD card
The image carries your household's names, so it's built from your household repository, on any Linux machine with Nix that can run ARM programs (on Debian or Ubuntu, `apt install qemu-user-static`). The Wi-Fi passphrase and the keys stay out of it.
1. In your household repository: `nix build --option extra-platforms aarch64-linux .#sd-image`.
2. In pdtv26's `box/`: `make card DEV=/dev/sdX` to check you have the right device, then `make flash DEV=/dev/sdX IMG=path/to/household/result/sd-image/*.img CONFIRM=erase`.
3. Also in `box/`: `make wifi-secret SSID=MyNetwork`: it puts the network's PSK on the card from the passphrase in your desktop keyring, not in the image or the repository. Store the passphrase there once, with `secret-tool store --label="Wi-Fi MyNetwork" service wifi ssid MyNetwork`.
4. Put the card in the Pi, plug in the IR emitter's USB cord, and power it up.
After this, changes to the box go over ssh, from your household repository: `nixos-rebuild switch --flake .#pimote --target-host pat@pimote.local --sudo --option extra-platforms aarch64-linux`.
## 4. Join the private network
On the box, the speech server, and the agent host: `tailscale up`, or whatever private network you use.
## 5. Make the keys, and start the brain
On the agent host, as the user the brain will run as, in pdtv26's `box/`:
1. `make keys BOX=pimote ADMIN=pat`: one key per connection, piped to both its ends; the box's ir and look keys come back for the brain. Put the camera's RTSP URL in `~/.config/pdtv26-camera/rtsp-url` first, or skip `rtsp-url`. If speech runs on another host, add `SPEECH=` that host: its key comes over ssh.
2. Make a fine-grained GitHub token for one repository, Issues read/write only, for problem reports, and save it as `~/.config/pdtv26-brain/report-token`.
3. `make -C ../brain install BOX=pimote REPO=you/your-repo ASSIGNEE=you`, then `make -C ../brain attach` once: log in, trust the folder, and approve the box's channel.
## 6. Tell it who it's for
The brain reads `~/pdtv26-brain/household.md`: who looks after it, who it serves, what they like to watch, what to be patient about. `make install` puts an example there; make it yours, and keep it in your household repository.
## 7. Teach it your remotes
Press the button and ask: "Learn my TV's power button." Point the TV's remote at the IR emitter and press **Power** when it asks. Do the same for **Input**, the cable box, and the rest. It keeps what it learns in its notes.