Sonos Controller based on NiceGUI
Project description
Sonos Moments
This is a simple web application based on SoCo and NiceGUI to control Sonos speakers in a local network. Its main feature is to capture "moments", i.e. the current state of the speakers, and to restore them later. This way, you can easily switch between different scenarios, e.g. your favorite radio station during breakfast in the kitchen, a relaxing playlist in the living room, or a party mix in the garden - all without having to use the original Sonos app. Especially since their latest update, the Sonos app has become quite buggy and slow, so this is a lightweight alternative for those who just want to control their speakers.
The official Sonos app for Android has an average rating of 1.2 stars on the Play Store. Even before the latest disastrous update, it was sometimes a pain to use. You want to start your morning routine with your favorite radio station in the kitchen, with a predefined volume, and all other speakers muted? That will take some time with the official app, especially when every page takes a few seconds to load, every click a few retries to succeed, and every change a few seconds to take effect. This sparked the idea for "Sonos Moments": capture recurring states of your speakers and restore them with a single click. Maybe it is even the beginning of a new, lightweight, fast and open-source Sonos app?
Infrastructure
Even though the first version of Sonos Moments was a mobile app implemented in C# using Xamarin.Forms a few years ago, it was time for a rewrite in Python. The upcoming web UI framework NiceGUI seemed like a perfect fit for this project, allowing for a much faster development cycle than with a mobile app. And we can use the existing SoCo library to interact with the Sonos speakers, avoiding the need for reinventing the wheel. The only downside is that the web app needs to run on a device in the same network as the Sonos speakers, but that is a limitation we can live with. An inexpensive Raspberry Pi Zero or similar device should do the job just fine. Another advantage of this setup is that we can easily store shared state on the server, e.g. the list of moments, without having to deal with synchronization issues between multiple clients.
Getting Started
To run Sonos Moments, you need a device in the same network as your Sonos speakers. This can be a Raspberry Pi, a laptop, or any other device that can run Python.
-
Install:
pip install sonos-moments
-
Run:
sonos-moments
The web interface will automatically open in your default browser at http://localhost:8080
.
If you want to access it from another device, you need to replace localhost
with the IP address of the server, which is printed in the console when the server starts.
Run sonos-moments --help
to see all available options, e.g. to change the port.
Usage
The web interface is quite simple and self-explanatory:
On the top panel there is a list of all available speakers. You can control the volume of each speaker individually, mute/unmute it, and play/pause the current track.
You can capture the current state of the speakers by clicking the button on the top right. A new moment will be added to the list below, with buttons to play, re-capture and delete it. Feel free to rename the moment to something more meaningful.
Vision
The most important feature of Sonos Moments, capturing and restoring the state of multiple speakers with a single click, is already implemented and works quite well. But there are many more features that could be added in the future:
- control the volume of multiple speakers at once
- set alarms and timers
- pause and auto-resume after a predefined time (e.g. for a commercial break)
- allow copy-pasting a YouTube/Spotify/SoundCloud/Mixcloud link to play it on the speakers
More ideas are welcome, and contributions are highly appreciated!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sonos_moments-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27776ce5be2fb48bdb729a7e76372b53c48f616074e3ae0d5e8fc990f1e0d795 |
|
MD5 | 5b5157039706d5ef238f878052dd356e |
|
BLAKE2b-256 | 163789cb958ca95f3f41332114f6734a708ba6d1c75cc9fbabfc2015e2b06f4c |