/astra-spotifarum

Control Spotify remotely with a Google Nest

Primary LanguagePythonMIT LicenseMIT

Astra Spotifarum

Control Spotify on your computer remotely with a Google Nest e.g. "hey Google, music pause". Useful if you typically listen to music in bed from your Desktop computer.

Google Nest has native support for Spotify remote control, so you should probably only use Astra if you have additional requirements to what they offer.

Works by connecting these services up to each other, in order:

  1. Google Nest
  2. IFTTT
  3. Adafruit MQTT
  4. Astra (this app)
  5. Spotify Web API
  6. Spotify on your computer

Based on Adorable QTPI

Requirements

Installation

  1. Install Python libraries: pip3 install -r requirements.txt
  2. Copy example.ini to config.ini
  3. Set up an MQTT topic:
    1. Set up an IO Adafruit account
    2. Create a new feed called astra
    3. In config.ini under mqtt set:
      • topic from Feed Info under the feed's name
      • username is from My Key -> Username at the top of the page
      • password is from My Key -> Active Key at the top of the page
  4. Set up a Spotify App:
    1. Create your Spotify app
    2. In config.ini under spotify set client_id/client_secret
    3. Edit your app settings to add the Redirect URI http://localhost:4000/callback
  5. Set up IFTTT:
    1. Create an IFTTT Applet
    2. Set If This to the Google Assistant trigger Say a phrase with both a number and a text ingredient
    3. Choose your activation phrase/reply, remembering to include the $ in the phrase e.g. "music $"
    4. Set Then That to Adafruit IO
    5. Choose your Feed from earlier as the Feed name
    6. For Data to save use Add ingredient and select TextField

Usage

  1. Run the script with python3 astra.py
  2. Log in to Spotify to give Astra access to control your Spotify player.
  3. Use the voice commands you set up in IFTTT to control playback:
  4. "hey google, music play" -> Plays music on Spotify desktop
  5. "hey google, music pause" -> Pauses music on Spotify desktop