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
adbcall intimeout(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
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.envVerify: 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.
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:5555Verify: 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:
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 # optionalVerify: 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
adb devicesshowsoffline/ commands hang →./scripts/adb-reconnect.sh(kill-server + connect).tailscale pingfails → 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.- 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. - Phone rebooted → ask the human to enable Wireless debugging; redo Step 4
tcpip 5555, restart keepawake, re-applydeviceidle disable. - A scheduled action failed → don't retry endlessly; report it and run it once manually if the user wants.