🎶 Play your favourite song when your Amazon Dash Button is pressed ⚡
- macOS or Linux (not tested on Windows)
- Node.js (v4.x and above)
- Python 2.x (required to install the
socketwatcher
npm module)
-
Install a dependency for play-music-dash.
This project depends on libpcap for reading packets. (This step can be skipped if your machine is macOS as it is installed by default on macOS and BSDs.)
# Ubuntu and Debian: sudo apt-get install libpcap-dev # Fedora and CentOS sudo yum install libpcap-devel
-
Clone and set up play-music-dash.
Note that Python 2.x is required in order to install
socketwatcher
(a dependency npm module of thenode-dash-button
module).git clone https://github.com/shoichiaizawa/play-music-dash.git cd play-music-dash # the command below installs `node-dash-button`, `simplayer` and their dependencies npm install
Setting up your Dash Button is as simple as following the instructions provided by Amazon EXCEPT FOR THE LAST STEP. Just follow the instructions to set it up in their mobile app. When you get to the step where it asks you to pick which product you want to map it to, just quit the setup process.
The button will be set up and available on your network.
Once your Dash Button is set up and on your network, you need to determine its MAC address. Run this:
sudo npm run scan
It will watch for new arp and udp requests on your network. There may be several such requests, so press it a few times to make sure. Copy the hardware address as shown below, and make a note of the protocol used.
Example:
$ sudo npm run scan
> play-music-dash@1.0.0 scan /Users/sho/github/play-music-dash
> node_modules/node-dash-button/bin/findbutton
Watching for arp & udp requests on your local network, please try to press your dash now
Dash buttons should appear as manufactured by 'Amazon Technologies Inc.'
Possible dash hardware address detected: 68:54:fd:**:**:** Manufacturer: unknown Protocol: udp
Possible dash hardware address detected: 68:54:fd:**:**:** Manufacturer: unknown Protocol: arp
For the above example, 68:54:fd:**:**:**
will be the MAC address of your
button.
-
Paste the MAC address discovered from the above step as shown below:
var dash = dashButton('68:54:fd:**:**:**', null, null, 'all');
-
Locate your favourite song in mp3 format under the
music
folder. -
Set the path for the mp3 file as shown below:
dash.on('detected', () => { console.log('Music is being played...'); // Locate an mp3 file under the `music` folder and set your favourite song // in the file path of the `musicProcess` function below var musicProcess = simplayer('music/music-title.mp3', function (error) { if (error) throw error; console.log('End of music.'); }); });
-
Run the following command to start the play-music-dash app:
Listening for Dash Buttons requires root. So you need to launch the app with
sudo
.sudo npm run start
-
Finally, press the configured button to play music 🎵
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
play-music-dash is build upon the following projects:
These posts and projects were helpful for making play-music-dash:
Copyright (c) 2017 Shoichi AIZAWA
Licensed under the MIT license.