home / skills / openclaw / skills / apple-media-officialpm

apple-media-officialpm skill

/skills/officialpm/apple-media-officialpm

This skill helps you discover and control Apple AirPlay devices on macOS, scanning networks, pairing, and managing playback and volume.

npx playbooks add skill openclaw/skills --skill apple-media-officialpm

Review the files below or copy the command above to add this skill to your agents.

Files (9)
SKILL.md
2.6 KB
---
name: apple-media
description: Discover and control Apple media/AirPlay devices (HomePod, Apple TV, AirPlay speakers) from macOS. Use when you want to scan for AirPlay devices, map names→IPs/IDs, pair/connect, and control playback/volume using pyatv (atvremote) and Airfoil.
---

# Apple Media (AirPlay + Apple TV control)

**Author:** Parth Maniar — [@officialpm](https://github.com/officialpm)

This skill is a thin workflow wrapper around two tools:

- **pyatv** (`atvremote`) for discovering Apple TVs/HomePods and (when supported/paired) remote-control style commands.
- **Airfoil** (via the existing `airfoil` skill) for reliable **speaker connect/disconnect + volume** control across AirPlay speakers (including HomePods).

## Setup

This skill uses `pyatv` installed via **pipx**.

Install/repair (pinned to Python 3.12 to avoid Python 3.14 asyncio issues):

```bash
pipx install pyatv || pipx upgrade pyatv
pipx reinstall pyatv --python python3.12
```

Verify:

```bash
atvremote --help | head
```

## Quick start

### 1) Scan the network for devices

```bash
# Fast scan (5s)
./scripts/scan.sh 5

# Faster scan when you know IP(s)
./scripts/scan-hosts.sh "10.0.0.28,10.0.0.111" 3

# Or JSON output
node ./scripts/scan-json.js 5
```

You’ll see devices like:
- HomePods (e.g., "Living Room", "Bedroom")
- Apple TV
- AirPlay-capable TVs

### 2) Control HomePod / speaker volume (recommended path)

Use Airfoil for speaker control (reliable for HomePods):

```bash
# List speakers Airfoil can see
../airfoil/airfoil.sh list

# Connect and set volume
./scripts/connect.sh "Living Room"
./scripts/volume.sh "Living Room" 35

# Disconnect (direct)
../airfoil/airfoil.sh disconnect "Living Room"
```

### 3) Apple TV remote commands (pyatv)

First, scan to find the Apple TV name or id, then run commands:

```bash
# Examples (device name can be Apple TV or other targets)
atvremote -n "TV" playing
atvremote -n "TV" play_pause
atvremote -n "TV" turn_on
atvremote -n "TV" turn_off
```

If you get auth/protocol errors, pairing/credentials are needed (device-dependent).

## Notes / gotchas

- **pyatv HomePod control often requires authentication** and may not support all remote-control commands out of the box.
  - When pyatv fails for HomePod playback/volume, prefer **Airfoil** for volume + speaker routing.
- `atvremote scan` is the source of truth for IP/ID discovery.

## Bundled scripts

### `scripts/scan.sh`

Runs `atvremote scan` with a configurable timeout.

```bash
./scripts/scan.sh 5
```

### `scripts/scan-json.js`

Parses `atvremote scan` output into a compact JSON summary (name, address, model, services).

```bash
node ./scripts/scan-json.js
```

Overview

This skill provides a lightweight macOS workflow to discover and control Apple media devices (HomePod, Apple TV, AirPlay speakers) using pyatv (atvremote) and Airfoil. It maps device names to IPs/IDs, handles pairing/connect tasks, and offers playback and volume controls via command-line scripts. The goal is reliable scanning and simple remote operations for AirPlay ecosystems from macOS.

How this skill works

The skill wraps pyatv (installed via pipx) for device discovery and remote commands and delegates speaker connect/disconnect and volume control to Airfoil for robust HomePod handling. Included scripts run atvremote scan, convert scan output to JSON, and expose simple connect/volume/remote commands by device name. When authentication or protocol limitations arise for HomePods, the skill prefers Airfoil for volume and routing.

When to use it

  • You need to scan the local network for Apple TVs, HomePods, or AirPlay-capable speakers.
  • You want a name→IP/ID map for devices to use in scripts or automation.
  • You need to issue simple Apple TV remote commands from macOS CLI.
  • You want reliable connect/disconnect and volume control for HomePods via Airfoil.
  • You need a compact JSON summary of discovered AirPlay devices for integration.

Best practices

  • Install pyatv with pipx and pin to Python 3.12 to avoid asyncio issues with newer interpreters.
  • Use atvremote scan as the source of truth for device discovery before issuing commands.
  • Prefer Airfoil for speaker volume and connect/disconnect on HomePods when pyatv behaves inconsistently.
  • Run short scans (5s) for quick checks and longer scans for larger networks or intermittent devices.
  • Store paired credentials securely if you need repeated authenticated control of Apple TV/HomePod.

Example use cases

  • Quickly locate all AirPlay devices and export a JSON list of names, IPs, and services.
  • Connect your Mac to a Living Room HomePod and set the speaker volume to 35% from a script.
  • Send play/pause or power commands to an Apple TV from a terminal-based automation.
  • Automate speaker routing before starting a presentation by connecting/disconnecting targets.
  • Validate device reachability and gather model/service details for troubleshooting an AirPlay setup.

FAQ

Do I need special Python to run pyatv?

Install pyatv via pipx and use Python 3.12 to avoid known asyncio compatibility problems with newer Python versions.

Why use Airfoil instead of pyatv for HomePod volume?

pyatv may require authentication and can have limited HomePod volume support; Airfoil provides more reliable connect/disconnect and volume control for AirPlay speakers.