DEV Community

Cover image for Open-source Sonos apps
Stephan
Stephan

Posted on • Originally published at svrooij.io

Open-source Sonos apps

Out of personal interest I've build several apps to have better control your Sonos speakers. This page will give you a brief overview of these apps.

Sonos2mqtt

Sonos2mqtt
npm
docker pulls
github sponsors

Sonos2mqtt is an application that let's you control your sonos speakers from your mqtt server. This application is mostly used by people who were already using mqtt in there home automation system.

Key features:

  • Quickly respond to changes to tracks (skip some artist in a "recommended songs"-playlist)
  • Group & Un-group players with a simple command
    • Players get removed from the group with your playbar in it (if you want), but they won't re-group after you stopped watching tv. With this app you can.
  • Truly lock volume of players (you immediately get volume updates and can instruct the player to turn down the volume).
  • Play notifications and revert to original song afterwards.
  • Play text to speak announce something in your house.
  • All the obvious music controls off-course, like Play, Pause, Next, Previous and a lot of other controls.

This is used alot, but because this is a local only app, without tracking inside, I can only see how often it's downloaded. Counting 334k pulls on docker and 24k downloads on NPM in the last 3 years. I can say there seems to be a solid user base.

Sonos-ts

Sonos typescript this library
npm
github sponsors

Control your sonos speaker from any node/typescript application. Some key features of this library are:

  • Basic controls of the speakers
  • Advanced device controls
  • Total local control, no cloud needed.
  • Listening to all events from the sonos speakers.
    • Track changes
    • Group changes
    • Volume
    • All other properties that emit events
  • Playing notifications, play a doorbell sound and automatically revert to the original playlist.
  • Text-to-speech generate an mp3 file for some text and play it as a notification. For instance to announce something or read a custom weather message
  • Interact with third party music services, like Spotify.

This library is supporting 95% percent of the original sonos application. I've also build a generator to generate the code interacting with the services, see below.

This library is downloaded 61.5k times in the last three year

Sonos alarms

Sonos API documentation and generator

I've also documented all the local endpoints of the sonos speakers. Actually the documentation is one of the products of the documentation generator.

The generator is used for the typescript library, but other could us it to generate strong typed classes for their own library.

The manual work laid in crafting this file. Containing all the documentation for a lot of services. PR's are highly appreciated.

Home automation

What does your ultimate home automation system look like? I'm curious to your home automation hacks.

Open source

github sponsors

All these applications are open-source, and while I do have a github sponsor profile, it doesn't make me a lot of money. So if anybody got suggestions on how to partially monetize these libraries, please send me a message.

It seems to be a rough world for open source maintainers. People think that there issue should always be solved with top priority. Recently I've put a new perk on my Github Sponsor profile for people that want me to quickly look at some issue. I will be referring to that when people harass me to fix an issue quickly.

Top comments (2)

Collapse
 
moopet profile image
Ben Sinclair

It always bothered me how Sonos built their products on Linux but didn't support it for clients. I used to work for a company that had their products around the office for our background office music but we ditched them after a while because of that, replaced with something running MPD iiirc.

What I did, which is probably not quite in the realm of normalcy, is to get a teasmade (if you remember them) and make it play different playlists based on when you turned the radio tuning knob. While switching "channels", it'd play a snippet of detuned FM or AM radio noise to make it sound more cheesy. Cheesy tea.

Sorry if this comment makes no sense I've had way too much coffee today already.

Collapse
 
svrooij profile image
Stephan

People are no also building jukebox for their kids with a bunch of RFID cards and an rfid reader. Scan a card to play a song.