Skip to content

Instantly share code, notes, and snippets.

@philfreo
Last active April 8, 2018 06:42
Show Gist options
  • Save philfreo/d87bd6ab8a059af8de20b0f9af9828b4 to your computer and use it in GitHub Desktop.
Save philfreo/d87bd6ab8a059af8de20b0f9af9828b4 to your computer and use it in GitHub Desktop.
Make Dash button play iTunes to AirPlay speakers

Uses a (basically free) Amazon Dash Button to play/pause your iTunes music over AirPlay speakers.

Requires OS X and an AirPlay compatible speaker (e.g. Apple TV or any speaker hooked up to AirPort Express).

  1. Install node-dash-button and follow the instructions to get your Dash Button's MAC address.
  2. Install node-applescript
  3. Tweak code as desired, filling in your button's MAC address, name of your AirPlay speakers, etc.
  4. Run via Terminal: node dash_buttons.js
const CASCADE = 'MAC_ADDRESS_HERE';
var applescript = require('applescript');
var dash_button = require('node-dash-button');
var dash = dash_button([CASCADE]);
dash.on("detected", function (mac) {
if (mac === CASCADE){
console.log("CASCADE BUTTON PRESSED");
applescript.execString('tell application "iTunes" to set selected of AirPlay device "Bonus Room Speakers" to true')
applescript.execString('tell application "iTunes" to playpause')
}
});

You can easily peel the front label sticker off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment