13 ms·
Sonos smart speaker controller API and CLI written in Rust
- The_rationalist 7y agoIf it wasn't in rust, would it show on HN?
- AndrewDucker 7y agoThis would be a lot more useful with some documentation and a readme.
- BozeWolf 7y agoI was about to say the same. Never understood the "read the source" attitude. If the developer wants to gain users or maybe even get help in developing it, at least a simple installation and usage example should be there. 15 minutes work for him, would save every user 30 or more minutes. Not going to try it because of this. A shame. Did find another interesting cli though: https://pypi.org/project/sonos-cli/ https://pypi.org/project/sonos-cli/
- tekstar 7y agoThe project is 12 days old. Maybe you could contribute instead of complaining?
- BozeWolf 7y agoI wish! All I can contribute is expressing my concerns. Don't want to be impolite, don't want to complain. Just express my concerns. I find it quite frustrating that open source/current company projects have no or little documentation. Even for a 12 days project it is frustrating. It is just good habit that documentation is as important as code. I like to say that if it has no documentation, it does not exist (to the user/contributor). I also think that code is a way of communicating with your future self or future developers. So clear code and clear documentation is important. Code is not important to the computer, the computer does not care about naming things.
- shakna 7y agoFrom another perspective: Whilst I am likely to spend far more time documenting than coding in my work, when I build something at home to fix a problem just for me I'm far less likely because it's for me. In the case of this particular developer, it isn't just for themselves, but also in a different language, and they've done their best just to reflect an existing API. They've asked for pull requests. I can understand not wanting to do the enormous amount of work of translating an API that is already pretty-much documented when I won't really see any return at all.
- xfitm3 7y agoAt first I was excited because the Sonos software stack frustrates me, but looking at source it just hits api.sonos.com. Would love to control the speakers directly on my LAN.
- bluejekyll 7y agoDo you know if the speakers are discoverable locally, and what protocol they use for that? I know Apple is all mDNS (for AirPlay), I don’t know anything about Sonos though.
- mcginleyr1 7y agoThey use SOAP on UDP. I played with it a while back using Sonex https://github.com/harmon25/sonex https://github.com/harmon25/sonex Have a fork to make some things work under my username.
- enigmo 7y agoSonos is (or was) mostly UPnP with some extensions... so for discovery they used SSDP https://en.wikipedia.org/wiki/Simple_Service_Discovery_Protocol https://en.wikipedia.org/wiki/Simple_Service_Discovery_Proto.... I messed around with their stack and internals for a while about ten years ago... some remnants remain https://github.com/NathanHowell/Sonority/tree/master/ https://github.com/NathanHowell/Sonority/tree/master/ https://github.com/NathanHowell/Sonority/tree/core/ https://github.com/NathanHowell/Sonority/tree/core/ https://github.com/NathanHowell/upd2 https://github.com/NathanHowell/upd2
- baroffoos 7y agoBluetooth.
- texs0987 7y agoHave you tried: https://github.com/SoCo/SoCo https://github.com/SoCo/SoCo Used it a bit seems to work most of the time
- echelon 7y agoTheir API used to allow this. It was all open protocols. Are they starting to lock it down through API updates? If so, that's terribly unfortunate and I'll have to rethink my audio setup and future purchases.
- FreeHugs 7y agoI never used Rust. Looking at the code, I see a "Cargo.toml" file that reminds me of composer.json and package.json in that it seems to contain dependencies. Where are these pulled from? Is this the same game as with other dependency managers in that you blindly trust a tree of code written by random people?
- GrayShade 7y agoThey're pulled from crates.io. I suppose it works as every other dependency manager, except that you can't have a left-pad because crates can't be removed. In this specific case, most dependencies are authored by people well-known and trusted in the community. The Rust standard library is pretty well-rounded (not compared to Python sense, but it's not like JavaScript either), so they're not something like left-pad or is-odd. You have there an error handling crate by the second most prolific Rust compiler contributor (if the counts are correct), an OAuth client, an HTTP one, a interactive line editor (like readline), _the_ serialization library in the ecosystem with its JSON support crate, a TOML config parser, the URL parser used by Servo and a crate for determining user paths on Unix.
- eb0la 7y agoWith cargo (Rust build tool) you don't need to use crates.io _always_ . For instance, you can target a repository and even a specific commit like this in gour cargo.toml file: [dependencies] package = { git = "https://github.com/...../something.git", rev = "commit_hash_like_9876541_for_instance" }
- GrayShade 7y agoYou can even host your own package registry, but I didn't think it would be worth mentioning in the context of that question.
- echelon 7y agoYou can still have your dependencies reference the source cargo packages, but overwrite it in a patch or vendor section. Don't specify the git repo directly in dependencies unless it's an unpublished crate.
- 0xdead 7y ago"Written in Rust". That alone makes it worthy of the frontpage.
- thomaslkjeldsen 7y agoSimilar project but for Beoplay & written in Swift: https://github.com/tlk/beoplay-macos-remote-cli https://github.com/tlk/beoplay-macos-remote-cli (shameless plug)
- ping_pong 7y agoI'm done with Sonos after they removed the ability to play music straight off the phone onto the speakers. The only way now to play music is via a service like Spotify or if you set up an mp3 server via SAMBA. They keeping cutting features and making their older speakers obsolete. I'm furious as an early adopter of Sonos that they are essentially bricking my older speakers or making them useless for no reason. I can't Airplay to them either because they are older. I can see in the next year or so them completely rendering my speakers useless, which is unethical. I'm done with them.
- SkyMarshal 7y agoOdd that they would do this, given there are plenty of competitors can be streamed to via Bluetooth, or HomePods which support AirPlay.
- texs0987 7y agoFor airplay on my old ones i run https://github.com/philippe44/AirConnect https://github.com/philippe44/AirConnect on a raspberry pi, works great
- 7y ago
- einpoklum 7y agoThe speakers are quite smart; the people willing to use them and get their entire life recorded by Google and Amazon - somewhat less smart. IMHO.
- tekstar 7y agoSonos sells speakers that don't have any alexa or google integration.
- einpoklum 7y agoWebsite: https://www.sonos.com/en-us/shop/one.html https://www.sonos.com/en-us/shop/one.html says "Google Assistant" and "Alexa Built-in".
- simonbh 7y agoYou can buy a One SL, Play:5, Playbar, or Playbase.
- NSAID 7y agoI own a couple of these. Because it has multiple options for virtual assistants, nothing is running out of the box as it wouldn't know which account to use or what service to route to. You have to go through an additional setup process after setting up the speaker for music playback.
- einpoklum 7y agoDo you know for certain that nothing is running silently out of the box? Or cannot be remotely triggered to run?
- TheDong 7y agoDo you know something is running / can be triggered? Someone can't prove a negative (X isn't running) as easily as a positive (X is), so the burden of proof should fall on you. Saying "yeah, but how do you know your toaster can't be remotely triggered to record you?" isn't useful. Maybe your threat model doesn't allow any hardware with a speaker that has updates, but that's not a reason to say it's an invalid setup for everyone's threat model nor to claim that, even without evidence, it's definitely going to be abused.
- kalekold 7y agoHave we all started to mention the language now when we write a piece of software?
- pletnes 7y agoOn hacker news, people are interested in hacking. I don’t know rust so that adds a barrier to entry for me, but might be nice for a rust programmer.
- echelon 7y agoI own Sonos and I program in Rust. Two interest points. Rust is trying to get to the threshold where it's applicable in the workplace. (All but a few major companies use it.) Unlike Golang, it needs all the cheerleading it can get to push it over that hurdle. I want to use Rust at work instead of Java.
- fortran77 7y agoWell, it's Rust! That means it will never crash, leak memory, or be susceptible to buffer overflow exploits. Plus it's fast! You can listen to a 2-minute song in 1 minute 50 seconds!
- swsieber 7y agoThis is golden. (And for those who aren't familiar with rust, it can leak memory and it tends to crash intead of exhibiting undefined behavior... but you could write it to listen to a 2 minute song at a faster pace :)
- The_rationalist 7y agoThis also apply with all garbage collected languages. So your argument is moot.
- kswillister 7y agoSimilar project but integrates with Spotify (written in node) https://github.com/kswilster/bronos https://github.com/kswilster/bronos (shameless plug)
- dandigangi 7y agoDocs are here if anyone is looking for what you can do: https://developer.sonos.com/reference/ https://developer.sonos.com/reference/ I'll assume not everything is covered.
- mlang23 7y agoYes, only the control API is implemented for now.
- denysvitali 7y agoI've actually built sonos-web [1] a couple of years ago, and started to rewrite it in Rust [2], but didn't have much time to do it. It should be a good place to start if anybody wants to extend it (: [1]: https://github.com/denysvitali/sonos-web https://github.com/denysvitali/sonos-web [2]: https://github.com/denysvitali/sonos-web-rs https://github.com/denysvitali/sonos-web-rs
- salamander014 7y agoLove this! If I create a group of speakers, how do I play something on them? If I have 2 speakers that are airplay-capable, Do I just pick one?
- p0cc 7y agoThe funny thing about Sonos speakers is that they run STP amongst themselves. If improperly configured, this can cause unexpected STP behavior on a network, and random ports to be shut off.
- luma 7y agoI wonder what the point of interest is with this project. Libraries for Sonos access have been available for well over a decade[1]. Is this interesting simply because a device with a well-documented API is now accessible from Rust? If not... what new information is being presented? [1] https://github.com/topics/sonos https://github.com/topics/sonos
- ben174 7y agoI find Home Assistant running on a Raspberry Pi more than capable of all the automation I could possibly need with my Sonos speakers along with almost any other device you can think of. https://www.home-assistant.io/ https://www.home-assistant.io/
- person_of_color 7y agoHow could I make a LED light show with Sonos? I would need to get FFT data of the audio and synchronize with Sonos. Is it possible?
- deleted 7y ago[deleted]