All projects

Sonos Optimizer: keeping Sonos happy on UniFi

Filip Wijnholds · · 2 min read

RustUniFiSonosClaude

Sonos and UniFi are both great on their own, and together they are a classic source of "why did the kitchen speaker just stop?" Sonos leans on multicast and discovery, UniFi has a lot of clever Wi-Fi features turned on by default, and the speaker gets caught in between. I got tired of digging through the controller every time one dropped out, so I built an app that does it for me.

Sonos Optimizer is a desktop app for Linux, written in Rust. It watches every Sonos speaker on the UniFi Wi-Fi, explains why one drops out, and fixes the network settings. Every change is backed up first and can be undone with one click.

The Monitor tab: every speaker as a row with a 24-hour connection strip and live link graphs
Monitor: every speaker, its signal and access point, and the last 24 hours at a glance.

What it does

  • Watches the speakers live. Signal, access point, band and uptime, and every 10 seconds it checks that each speaker actually answers.
  • Remembers what happened. Drop-outs and access-point moves are kept for 24 hours, with a desktop notification when a speaker goes offline.
  • Explains drop-outs. It reads 14 days of the controller's history for one speaker and ranks the likely causes, with the evidence.
  • Fixes settings safely. Every change is previewed, a backup is saved first, and History reverts anything.
  • Plays music too. Group control, volume and your Sonos Favorites from the Playback tab.
The Diagnose tab: the likely cause in red and findings ranked by how likely they are
Diagnose: findings ranked as likely, possible or info, each with what was seen and what to do.

Claude as the network engineer

The part I enjoyed building most is the assistant. Paste a Claude API key and ask in plain language: why does the kitchen speaker cut out? Claude reads the same data you see, runs diagnoses and previews fixes on its own. Nothing on the network changes until you press Apply change: the app shows the plan and waits for you.

A suggested fix, the 14-day session chart and the list of roams and disconnects
A suggested fix, with 14 days of sessions per access point underneath.

Safe by design

  • Nothing changes without you. Every change is previewed, and Claude can only act after you approve.
  • Everything can be undone. A version is saved before every change.
  • Keys stay local. The UniFi and Claude keys live in your home folder, readable only by you, and are never sent to Claude.
  • Usage stats are opt-in. Anonymous crash reports and timings only if you say yes on first start.
The History tab: a timeline of saved versions and what each changed
History: every change is a version you can preview and revert.

The code, a user guide and build instructions are on GitLab. You need a UniFi console (UDM, UDM Pro, Cloud Key Gen2+ or a self-hosted Network app).

I build and test it on Linux. It uses cross-platform libraries, so it should also compile on macOS and Windows, but I haven't tried that yet, and desktop notifications only work on Linux for now. Looking for Windows testers: if you run UniFi and Sonos on a Windows machine and want to give it a go, open an issue on GitLab or get in touch.

View the code on GitLab