Automated switching of Chromecast endpoint for audio based on location / bluetooth

108 views
Skip to first unread message

Barney Craggs

unread,
Nov 29, 2016, 9:13:49 AM11/29/16
to Tasker
Hey all

I haven't used Tasker for a year or two but have been drawn back in after watching a video showing how the Chromecast audio's have a decent sync feature allowing for music to be played to multiple speakers at once.

This got me wondering.  Sure this is a great use-case but could I use Tasker to switch the audio output to which-ever Chromecast audio I was nearest to?  As all of mine are connected to bluetooth enabled speakers (don't get me started on why not just use BT for audio) I was thinking something like using that bluetooth as a locale beacon which Tasker would recognise and then switch output to associated Chromecast.   Now when I walk around the house, rather than every speaker working, the music follows me.

Any thoughts on how this might be accomplished? 

Cheers

Miles M

unread,
Nov 30, 2016, 1:40:07 AM11/30/16
to Tasker
Thats a great idea, I might try to implement it myself. It may get a bit complicated however.

This could be done using BlueTask to poll what bt devices are available every 30~ secs whenever music is playing and if you're connected to your home wifi and/or you're connected to chromecast (however you want to detect that, perhaps notification?), storing the closest bluetooth beacon in a variable. You can tell which bluetooth beacon is closest by measuring its signal strength, which is the RSSI value (also returned by BlueTask)
If the stored "closest" beacon is no longer the beacon of the highest RSSI (and the difference between the RSSI values is significant), have tasker reconnect to the new closest beacon in the returned list. If the speakers aren't the same model, it may cause problems correctly choosing the closest beacon, since the RSSI vs Distance may vary by speaker.

How you connect to the chromecast varies by the music playing app (I am not familiar with how audio chromecast plays regular music; as such, neither am i familiar with how tasker can control this. this may help). I myself use spotify, which can directly control chromecast devices. Since I don't believe there is an android intent for controlling these chromecast devices through spotify, I will likely rely on my main computer to switch devices by brute force in the Windows Spotify app using EventGhost, and AutoRemote (eg plugin) to control them. For general purpose, use AutoNotification to start playing music again by notification if needed (or Spotify intents, or device music play (action in tasker))

Good luck, if you have any questions I will gladly help :)
Miles
Reply all
Reply to author
Forward
0 new messages