homebridge-agent-atv

中文文档
0.2.0发布于 2026/11/04MITCommonJS

Control an Apple TV from AI agents: an authenticated HTTP API (pyatv bridge), keyboard input, wait conditions, optional screen reading (focused element, screenshots), and a minimal HomeKit TV accessory.

原始使用文档
文档目录5 节
  1. Requirements
  2. Setup
  3. Security
  4. Configuration
  5. License

homebridge-agent-atv

A Homebridge plugin that lets AI agents drive an Apple TV. It exposes an authenticated HTTP API that the agent-atv CLI talks to: remote keys, app launching, keyboard text input, wait conditions, power, volume, seek and optional screen reading (the focused element after an action, and screenshots). It also publishes a minimal HomeKit TV accessory.

It complements homebridge-appletv-enhanced: that plugin is about HomeKit control, this one is an API for agents. Both can run side by side.

The full guide (setup, pairing, screen reading, the CLI, security, troubleshooting) is the main README.

Requirements

  • Homebridge 1.8 or 2.x, Node.js 22.12+, 24 or 26.
  • Python 3.10 to 3.13 with the venv module (sudo apt-get install python3-venv on Debian/Ubuntu) and OpenSSL 3.0+. On first start the plugin creates its own virtual environment in <storage>/agent-atv/.venv and installs the pinned pyatv 0.18.0 dependencies from PyPI. This takes a few minutes on a Raspberry Pi.
  • Screen reading (optional): about 350 MB more in <storage>/agent-atv/.venv-screen, and about 100 MB of memory per Apple TV. On Python 3.10–3.12 the install compiles one package, so the host needs build-essential python3-dev libssl-dev (Debian/Raspberry Pi OS).

Setup

  1. Install the plugin from the Homebridge UI (or npm i -g homebridge-agent-atv) and add the platform.

  2. Open the plugin settings. Apple TVs on the network appear in the device table. Click Pair, then type the PIN shown on the TV. The plugin pairs Companion first, then AirPlay if the Companion credentials don't work for AirPlay (a second PIN), then screen reading when it is on (one more PIN). Check Also enable screen reading before pairing to turn it on from there.

  3. Copy the API token from the same page, then on the agent's machine:

    npm i -g agent-atv
    agent-atv config set url http://<homebridge-host>:8787
    agent-atv config set token -     # paste the token, Enter, Ctrl-D
    agent-atv doctor
    

Security

The API is plain HTTP with a bearer token. The token gives full remote control of every paired Apple TV.

  • Prefer binding the API to the host's Tailscale IP (api.bind), which encrypts the traffic. On a LAN, anyone who can sniff the network can read the token.
  • The token is stored in <storage>/agent-atv/token (mode 0600) and shown in the plugin settings. It is never logged. To rotate it, delete that file and restart Homebridge, or set api.token (32+ characters).
  • Pairing credentials stay in <storage>/agent-atv/devices/ (mode 0600). They never appear in logs, API responses or the settings UI.
  • No telemetry: the plugin only talks to your Apple TVs, and to PyPI while installing its pinned packages.

Configuration

keydefaultmeaning
api.port8787HTTP API port
api.bind0.0.0.0listen address, e.g. 127.0.0.1, a LAN IP or the Tailscale IP
api.token""overrides the generated token (32+ characters)
discovery.enabledtruescan on start and every 5 minutes
discovery.hosts[]IPs to scan directly (other subnets, Tailscale)
devices[][]per-device id, name, address, homekit
homekit.enabledtruepublish one HomeKit TV accessory per paired Apple TV
homekit.inputs / homekit.maxInputs[] / 12apps exposed as TV inputs
screen.enabledfalsescreen reading: foreground app, focused element, screenshots
python.executablepython3interpreter used to build the venv
python.forceVenvRecreatefalserebuild the venv on next start
debugfalselog debug lines at info level

The HomeKit accessory is published as an external accessory: add it in the Home app with Add Accessory > More options and the Homebridge setup code.

The HTTP API is specified in DESIGN.md.

License

MIT

版本与发布记录

homebridge-agent-atv 共发布 5 个版本,首次发布于 2026/11/02;过去 12 个月发布了 5 个版本。

版本发布日期距今
0.2.0latest2026/11/04今天
0.1.22026/11/031 天前
0.1.12026/11/021 天前
0.1.02026/11/021 天前
0.0.0-stage2026/11/021 天前

关于 homebridge-agent-atv 的常见问题

homebridge-agent-atv 是什么?

通过AI代理控制Apple TV:一个经过身份验证的HTTP API (pyatv bridge)、键盘输入、等待条件、可选的屏幕读取(焦点元素、截图)和一个最小的HomeKit TV配件。

如何安装 homebridge-agent-atv?

在项目目录运行 npm install homebridge-agent-atv,或使用 pnpm add / yarn add / bun add。

homebridge-agent-atv 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/homebridge-agent-atv 是否存在。

homebridge-agent-atv 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

homebridge-agent-atv 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.12.0 || ^24.0.0 || ^26.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

homebridge-agent-atv 可以商用吗?

homebridge-agent-atv 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

homebridge-agent-atv 还在维护吗?

最新版本 0.2.0 发布于 2026/11/04(今天);至今共发布 5 个版本,其中过去 12 个月发布了 5 个;首次发布于 2026/11/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。