stephen / airsonos

:musical_note: AirPlay to Sonos
MIT License
2.1k stars 252 forks source link

Adapt to speakers getting grouped / un-grouped #369

Open ndfred opened 7 years ago

ndfred commented 7 years ago

If I start AirSonos, then group speakers I will still see two speakers in the AirPlay list. If I group speakers, then start AirSonos I will see only one speaker, but it will be named after the speaker I started the group with rather than the name of the group.

If possible it would be nice to detect grouping / un-grouping events and update the list of AirPlay speakers as a consequence. Naming grouped speakers correctly would be a nice addition too.

ThatGit10 commented 7 years ago

+1. Automated restarting of airsonos when groupings change would be excellent.

My first "solution" to this issue was to use Screens app on my iPhone to remote into my Macbook Pro, which I run as a server to host things like AirSonos. Once in my Macbook, I Ctrl-C the existing airsonos instance running in terminal and start again.

The next step was to use SSH instead of Screens. I could run airsonos from the SSH app.But as soon as I closed the iPhone app, airsonos would stop running. My "hack" to get around this is pretty simple:

  1. SSH into server.
  2. Run "screen"
  3. Launch airsonos via screen.
  4. Disconnect from screen.
  5. Close terminal app.

If I do this, airsonos remains running. When I change groupings, I remote back into the server, reattach to the screen (screen -r). Ctrl-C the existing airsonos instance, run airsonos again, disconnect from screen, and go one with my day.

I can think of two ways this could be easier:

  1. Automated restarting of airsonos with groupings change -- gold standard
  2. A quick command to manually restart airsonos from the command line. I tried using npm restart airsonos But that gave me an error and had no effect.
ndfred commented 7 years ago

That's pretty much what I do as well, easiest would really be to detect group changes and re-configure accordingly

markjaquith commented 7 years ago

This is a good idea (if it's possible!). For now, my solution is to use the "Workflow" app on iOS to run this script over SSH:

ps aux | grep airsonos | grep -v grep | awk '{print "BEFORE\nid:",$2"\nCPU:",$3"%\nSince:",$9}'
killall node
airsonos > /dev/null 2>&1 &
echo ""
ps aux | grep airsonos | grep -v grep | awk '{print "AFTER\nid:",$2"\nCPU:",$3"%\nSince:",$9}'
exit