Skip to content

Latest commit

 

History

History
executable file
·
89 lines (72 loc) · 2.38 KB

README.md

File metadata and controls

executable file
·
89 lines (72 loc) · 2.38 KB

IFTTT support for Spotify Connect (using Webhook)

Transfer playback between your devices using Spotify Connect. To be used with Google Assistant, Flic button etc.

This example uses Google Cloud Functions, but can be deployed elsewhere too.

Configure Google Cloud Functions

  1. Install and initialize Google Cloud Functions as described on https://cloud.google.com/functions/docs/tutorials/http
  2. Authenticate Google Cloud by running
gcloud auth login
  1. Configure Google Cloud project (if authentication didn't set you up with the correct one).
gcloud config set project PROJECT_ID

Configuration

  1. Install dependencies with
npm install
  1. Create an application on Spotify for Developers.
  2. Add redirect uri http://localhost:8888/callback
  3. Create a config.json file (based on config.default.json) and update CLIENT_ID and CLIENT_SECRET from the Spotify application you just created.
  4. Start configuration by running
node setup.js
  1. (Optional) Add keywords to your devices in config.json (lowercase)

Test

Test your configuration by running

npm run test

This should start playback to the first device in your list. It can also take an argument of a device:

npm run test -- "MySpeaker"

Deploy

To deploy to Google Cloud Functions run

npm run deploy

Set up IFTTT WebHook trigger

Set up a new WebHook trigger with the URL displayed after deploy, something in the form of https://{YOUR-REGION}-{YOUR-PROJECT-ID}.cloudfunctions.net/playOnDevice

Select method POST, Content-Type to application/json and set body to:

{
  "device": "{{TextField}}",
  "secret": "{YOUR-SECRET-IN-CONFIG.JSON}"
}

API

All calls should be made with POST method.

/playOnDevice

Activate playback on given device

Parameters

secret Your shared secret for authentication

device The name (or one of the keywords) of the device to move playback to

/skipNext

Skip to next track

Parameters

secret Your shared secret for authentication

/skipPrevious

Skip to previous track

Parameters

secret Your shared secret for authentication

/pause

Pause playback

Parameters

secret Your shared secret for authentication