---
name: android-home-server
description: Set up and operate a spare non-rooted Android phone as a Linux home server and home-automation hub (Termux + SSH, Tailscale, ADB over network) to control WiZ lamps, a Sony Bravia TV, camera apps and phone settings remotely. Use when asked to set up, check, repair or use the Android home server, lamps, TV or phone automation.
title: android-home-server
canonical_url: https://skilld.dev/gh/romit07/android-home-server
last_updated: 2026-11-01T09:01:07.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> 21 supporting files sit beside this SKILL.md. When the Skill refers to one, fetch https://skilld.dev/api/skills-raw/romit07/android-home-server/android-home-server/PATH with PATH replaced.
>
> If the user asked to install this Skill, run `npx skilld install romit07/android-home-server/android-home-server`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/android-home-server`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/romit07/android-home-server/android-home-server) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/android-home-server`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/android-home-server --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/android-home-server --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# Android Home Server skill

You are an agent with a shell on a **controller** machine (laptop, VPS or cloud box). The **phone** is a spare, non-rooted Android device on the user's home Wi-Fi. You reach it only over **Tailscale**. Repo: https://github.com/romit07/android-home-server

## Ground rules
- Never expose ADB or SSH to the public internet. Use the phone's Tailscale address only.
- Wrap every `adb` call in `timeout` (e.g. `timeout 20 adb ...`). Half-dead links hang forever.
- Never install apps on the phone, rename things, or change settings beyond what the user asked; ask first.
- Some steps need the human (tapping on the phone, pairing codes, signing in). Ask for exactly that step, then verify.
- Don't send screenshots to the user unless asked; prefer `scripts/ui.sh` (text) to check screen state, delete screenshots afterwards.
- Keep secrets (keys, IPs, MACs) in `config.env`, never in commits or chat logs that go public.

## Setup (do in order, verify each step)

### Step 1. Controller tools
```bash
sudo apt-get install -y adb openssh-client python3 git   # or brew install android-platform-tools
git clone https://github.com/romit07/android-home-server && cd android-home-server
cp config.example.env config.env
```
**Verify:** `adb version && ssh -V && python3 --version` all succeed.

### Step 2. Tailscale on both ends
Human: install Tailscale on the phone (Play Store) and sign in. Install on the controller (`curl -fsSL https://tailscale.com/install.sh | sh && sudo tailscale up`) with the same account.
**Verify:** `tailscale status` lists the phone; `tailscale ping <phone>` gets a pong (via DERP is OK). Put the name/IP in `PHONE_HOST`.

### Step 3. Termux + SSH
Human: install Termux from F-Droid, open it, run:
`pkg install -y curl && curl -fsSL https://raw.githubusercontent.com/romit07/android-home-server/main/scripts/termux-setup.sh | bash`
Then add the controller's public key: generate with `ssh-keygen -t ed25519 -f ~/.ssh/android_termux -N ''`, and have the human paste the `.pub` into Termux `~/.ssh/authorized_keys` (or use `ssh-copy-id -p 8022` with the temporary `passwd`). Set `SSH_USER` (Termux `whoami`) and `SSH_KEY` in `config.env`.
**Verify:** `ssh -i $SSH_KEY -p 8022 $SSH_USER@$PHONE_HOST 'uname -a; python --version; which nc nmap'` prints Linux/aarch64 and paths.

### Step 4. ADB over network
Human: enable Developer options (tap Build number 7x), turn on Wireless debugging, open "Pair device with pairing code", tell you IP, pairing port, code and debug port.
```bash
timeout 30 adb pair <ip>:<pair-port> <code>
timeout 15 adb connect <ip>:<debug-port>
timeout 15 adb -s <ip>:<debug-port> tcpip 5555
timeout 15 adb connect $PHONE_HOST:5555
```
**Verify:** `timeout 15 adb devices` shows `<PHONE_HOST>:5555  device` and `./scripts/adb-reconnect.sh` prints `connected`.

### Step 5. Keep-alive
Ask the human to: keep it charging; set Termux + Tailscale battery to Unrestricted; set Tailscale as Always-on VPN; optionally Developer options → Stay awake. Then:
```bash
adb -s $PHONE_HOST:5555 push scripts/keepawake.sh /data/local/tmp/
timeout 10 adb -s $PHONE_HOST:5555 shell 'nohup sh /data/local/tmp/keepawake.sh >/dev/null 2>&1 &'
timeout 10 adb -s $PHONE_HOST:5555 shell dumpsys deviceidle disable    # optional
```
**Verify:** `timeout 10 adb -s $PHONE_HOST:5555 shell 'ps -A | grep -c keepawake'` ≥ 1; `dumpsys deviceidle enabled` prints 0 if disabled.

### Step 6. WiZ lamps (optional)
Get bulb MACs (WiZ app → bulb → settings, or router client list) into `BULB_MACS`, set `LAN_PREFIX`.
**Verify:** `./scripts/lamps.py discover` finds every MAC; `./scripts/lamps.py status` returns JSON from each bulb; `./scripts/lamps.py day` logs `DAY ok`.
Schedule: set `LAMP_SCHEDULE`, start `nohup python3 scripts/scheduler.py >/dev/null 2>&1 &`. Also suggest the human create the same schedules in the WiZ app (Automation → Schedules) as a backup that runs on the bulbs themselves.

### Step 7. Sony Bravia (optional)
Human: TV Settings → Network → Home network → IP control → Simple IP control ON (and Authentication "Normal and Pre-Shared Key" if present). Put `TV_IP` in config (find via `ip neigh` on the phone / router).
**Verify:** `./scripts/tv.sh status` returns `*SAPOWR000000000000000X`. For apps, enable network debugging on the TV, run `./scripts/tv-adb.sh youtube` and ask the human to accept the ADB prompt on the TV once.

## Operating commands
| Task | Command |
|---|---|
| Health check | `tailscale ping $PHONE_HOST; ./scripts/adb-reconnect.sh` |
| Lamps | `./scripts/lamps.py day\|on\|night\|warm\|off\|status\|discover` |
| TV | `./scripts/tv.sh on\|off\|status\|vol N\|mute\|input hdmiN`; `./scripts/tv-adb.sh youtube\|url URL` |
| Silence phone | `./scripts/dnd.sh on` / `off` / `status` / `until 23:59` (alarms-only; always schedule the off) |
| Read screen | `./scripts/ui.sh` (text, ids, bounds, CLICK flags) |
| Drive an app | `./scripts/tap.sh open <pkg>`, `./scripts/tap.sh text "<label>"`, `./scripts/tap.sh X Y` |
| Linux on phone | `ssh -i $SSH_KEY -p 8022 $SSH_USER@$PHONE_HOST '<cmd>'` |

App automation loop (WiZ app, camera apps, anything): `ui.sh` → pick the element → `tap.sh` → `ui.sh` again to confirm the new state. Never assume a tap worked.

## Recovery playbook
1. `adb devices` shows `offline` / commands hang → `./scripts/adb-reconnect.sh` (kill-server + connect).
2. `tailscale ping` fails → the phone is off Tailscale or off Wi-Fi. Ask the human to open Tailscale on the phone; a "DNS unavailable" warning = bad Wi-Fi → restart router/extender.
3. Bulbs/TV not found → ping sweep (`lamps.py discover`); if still missing, ask the human to restart the Wi-Fi extender (devices often drop off it). IPs shuffle after power cuts; always match by MAC.
4. Phone rebooted → ask the human to enable Wireless debugging; redo Step 4 `tcpip 5555`, restart keepawake, re-apply `deviceidle disable`.
5. A scheduled action failed → don't retry endlessly; report it and run it once manually if the user wants.
