n8n Workflow
Expert

Control Spotify with an IKEA Remote via MQTT

Automate your Spotify playback using a physical IKEA smart remote. This n8n workflow listens for MQTT messages to control volume, play/pause, skip tracks, and trigger custom playlists.

Overview

Remotely control Spotify playback and trigger complex actions using a physical IoT button, like an IKEA remote, connected via MQTT.

🧠 Description & Use Case

This workflow transforms a physical IoT button, such as an IKEA 5-button remote, into a versatile and powerful Spotify controller. By listening to MQTT messages sent from the remote, it can manage playback, adjust volume, and even execute multi-step custom actions.

🔄 How It Works:

  1. Trigger on Button Press

    • The MQTT Trigger node listens for actions from a Zigbee-enabled remote (e.g., an IKEA smart switch) that is connected via a service like Zigbee2MQTT.
  2. Set Global Variables

    • A Set node (Globals) configures key parameters like the name of the target Spotify playback device (e.g., "My Smart-Speaker Playback Device") and a favorite playlist name. This makes the workflow easy to customize.
  3. Initial Action Routing

    • A Switch node (Remote Action -> Function Router) reads the incoming MQTT message (e.g., arrow_left_click, toggle) and directs the workflow.
    • Simple actions like Next and Previous track are executed immediately for a fast response.
  4. Device Check & Activation

    • For more complex actions (volume, play/pause, custom functions), the workflow first ensures music is playing on the correct device.
    • It calls the Spotify API to get the current device status. An If node checks if the active device matches the target device set in the Globals.
    • If not, it fetches a list of available devices, finds the correct one by name, and activates it.
  5. Execute Playback Command

    • Once the correct device is active, a second Switch node (Route to Requested Function) executes the specific command from the button press:
      • Volume Up/Down: Uses HTTP Request nodes to increase or decrease the volume by 5%.
      • Play/Pause: An If node checks the current playback state and toggles between Pause and Resume.
      • Custom Functions: The "hold" actions on the remote trigger unique, multi-step macros:
        • Custom Function 1: Sets a specific volume, adds a predefined track to the queue, and skips to it.
        • Custom Function 2: Finds a user-defined favorite playlist (e.g., "Discover Weekly") and starts playback.

✅ Real-World Use Cases:

  • Tactile Music Control: Add physical, guest-friendly controls for your Spotify music anywhere in your home, without needing a phone or computer.
  • Smart Home Integration: Seamlessly integrate Spotify into your smart home ecosystem, using one remote to control music, lights, and more.
  • Custom Music Macros: Create powerful one-press shortcuts. For example, a long press could trigger your "Workout" playlist and set the volume to 70%.
  • Party Mode Starter: Dedicate a button to instantly start a specific party playlist on a designated group of speakers.

Instructions

Basic steps

  1. Download workflow JSON
  2. Import into n8n
  3. Configure node parameters as needed
  4. Test and enable the workflow

💡 Tips

After importing, verify all connectors and credentials match your environment.

Preview

Workflow Visualization

26 nodes
100%
Spotify NextspotifySpotify ResumespotifySpotify PausespotifySticky NotestickyNoteSpotify API - Volume up 5pcthttpRequestSpotify API - Volume down 5pcthttpRequestSticky Note8stickyNoteSpotify API - Get Available DeviceshttpRequestExtract Individual DevicessplitOutSelect Device by Name to get device_idfilterCustom Function 1 - P1httpRequestCustom Function 2 - P2spotifyCustom Function 1 - P3spotifySpotify API - Activate Target Playback DevicehttpRequestRoute to Requested FunctionswitchCustom Function 2 - P1spotifyFilterfilterGlobalssetCustom Function 2 - P3spotifyOops. How was this reached?noOpSpotify API - Get Device StatushttpRequestAlready playing on Target Device?ifIs Playing?ifSpotify PrevspotifyMQTT Trigger - Remote SwitchmqttTriggerRemote Action -> Function Routerswitch

Nodes

1

Spotify Next

spotify

v1
2

Spotify Resume

spotify

v1
3

Spotify Pause

spotify

v1
4

Sticky Note

stickyNote

v1
5

Spotify API - Volume up 5pct

httpRequest

v4.1
6

Spotify API - Volume down 5pct

httpRequest

v4.1
7

Sticky Note8

stickyNote

v1
8

Spotify API - Get Available Devices

httpRequest

v4.1
9

Extract Individual Devices

splitOut

v1
10

Select Device by Name to get device_id

filter

v2
11

Custom Function 1 - P1

httpRequest

v4.1
12

Custom Function 2 - P2

spotify

v1
13

Custom Function 1 - P3

spotify

v1
14

Spotify API - Activate Target Playback Device

httpRequest

v4.1
15

Route to Requested Function

switch

v3
16

Custom Function 2 - P1

spotify

v1
17

Filter

filter

v2
18

Globals

set

v3.4
19

Custom Function 2 - P3

spotify

v1
20

Oops. How was this reached?

noOp

v1
21

Spotify API - Get Device Status

httpRequest

v4.1
22

Already playing on Target Device?

if

v2
23

Is Playing?

if

v2
24

Spotify Prev

spotify

v1
25

MQTT Trigger - Remote Switch

mqttTrigger

v1
26

Remote Action -> Function Router

switch

v2

Statistics

Total nodes:26
Disabled nodes:0
Node types:10
Connections:15
View full JSON structure
{
  "nodes": [
    {
      "id": "169e3a8c-82f5-4527-a187-27b8e5d903c1",
      "name": "Spotify Next",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1300,
        -40
      ],
      "parameters": {
        "operation": "nextSong"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7840d6b8-7eb4-4ac2-8bd0-946561f7de38",
      "name": "Spotify Resume",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1300,
        660
      ],
      "parameters": {
        "operation": "resume"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "35e768a3-b648-4d5e-a6a4-fa5f5be3d922",
      "name": "Spotify Pause",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1300,
        480
      ],
      "parameters": {
        "operation": "pause"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0a391400-a8f0-4c1e-ac79-bbdea4aa21b4",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -361,
        55
      ],
      "parameters": {
        "width": 611.1911357340722,
        "height": 291.1542012927053,
        "content": "### Receive MQTT message from IKEA 5-button Switch, and route actions."
      },
      "typeVersion": 1
    },
    {
      "id": "164e904f-278d-4e48-81de-e1fc050e683a",
      "name": "Spotify API - Volume up 5pct",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1300,
        120
      ],
      "parameters": {
        "url": "https://api.spotify.com/v1/me/player/volume",
        "method": "PUT",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "=device_id",
              "value": "={{ $json.device.id }}"
            },
            {
              "name": "volume_percent",
              "value": "={{ Math.min($json.device.volume_percent + 5, 100) }}"
            }
          ]
        },
        "nodeCredentialType": "spotifyOAuth2Api"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 4.1,
      "alwaysOutputData": true
    },
    {
      "id": "a75cfc9b-ba21-4771-a2ff-f7aee843f344",
      "name": "Spotify API - Volume down 5pct",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1300,
        300
      ],
      "parameters": {
        "url": "https://api.spotify.com/v1/me/player/volume",
        "method": "PUT",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "device_id",
              "value": "={{ $json.device.id }}"
            },
            {
              "name": "volume_percent",
              "value": "={{ Math.max($json.device.volume_percent - 5, 20) }}"
            }
          ]
        },
        "nodeCredentialType": "spotifyOAuth2Api"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 4.1,
      "alwaysOutputData": true
    },
    {
      "id": "deae216d-aaaa-406c-b978-45b790c5d837",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -360,
        608.2274931489221
      ],
      "parameters": {
        "color": 5,
        "width": 906.3175117167951,
        "height": 278.7021481044274,
        "content": "### Find the target player device (or spotify device group) by name, and activate it."
      },
      "typeVersion": 1
    },
    {
      "id": "2733fd1e-4c58-4f3e-bf7d-f4111fea6efc",
      "name": "Spotify API - Get Available Devices",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -260,
        680
      ],
      "parameters": {
        "url": "https://api.spotify.com/v1/me/player/devices",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {}
          ]
        },
        "nodeCredentialType": "spotifyOAuth2Api"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 4.1,
      "alwaysOutputData": true
    },
    {
      "id": "1d7fcab5-e49d-4d03-8e7d-aa339afa45ec",
      "name": "Extract Individual Devices",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -60,
        680
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "devices"
      },
      "typeVersion": 1
    },
    {
      "id": "7ae0af1c-2fbb-47e4-b2ab-670be441d86f",
      "name": "Select Device by Name to get device_id",
      "type": "n8n-nodes-base.filter",
      "position": [
        140,
        680
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "069d11c8-75a2-4a5c-81c4-e6f771ee4829",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.name }}",
              "rightValue": "={{ $('Globals').first().json.target_spotify_playback_device_name }}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "738d57fd-9dcb-4d3d-b070-73867c926d3f",
      "name": "Custom Function 1 - P1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        880,
        840
      ],
      "parameters": {
        "url": "https://api.spotify.com/v1/me/player/volume",
        "method": "PUT",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "volume_percent",
              "value": "80"
            }
          ]
        },
        "nodeCredentialType": "spotifyOAuth2Api"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 4.1,
      "alwaysOutputData": true
    },
    {
      "id": "e3fc6784-1612-427d-9b78-a3f4050ed176",
      "name": "Custom Function 2 - P2",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1080,
        840
      ],
      "parameters": {
        "id": "spotify:track:4PTG3Z6ehGkBFwjybzWkR8"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "340f23ff-ae8a-4032-a641-30bc32af09c7",
      "name": "Custom Function 1 - P3",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1300,
        840
      ],
      "parameters": {
        "operation": "nextSong"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "30a413da-5ce3-44a9-a43e-c6679b712087",
      "name": "Spotify API - Activate Target Playback Device",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        360,
        680
      ],
      "parameters": {
        "url": "https://api.spotify.com/v1/me/player",
        "method": "PUT",
        "options": {},
        "jsonBody": "={\n  \"device_ids\": [\n    \"{{ $('Select Device by Name to get device_id').first().json.id }}\"\n  ],\n  \"play\": true\n}",
        "sendBody": true,
        "sendQuery": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {}
          ]
        },
        "nodeCredentialType": "spotifyOAuth2Api"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 4.1,
      "alwaysOutputData": true
    },
    {
      "id": "91dd48fe-6c3c-4170-8392-3d9885e61047",
      "name": "Route to Requested Function",
      "type": "n8n-nodes-base.switch",
      "position": [
        900,
        420
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "=volume_up",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('MQTT Trigger - Ikea Remote Switch').first().json.message }}",
                    "rightValue": "brightness_up_click"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "volume_down",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "c0726ee0-31b2-48fd-a860-0b923d8c18e7",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('MQTT Trigger - Ikea Remote Switch').first().json.message }}",
                    "rightValue": "brightness_down_click"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "play/pause",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "569014d8-0db4-4126-a0dd-7264a3b6db51",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('MQTT Trigger - Ikea Remote Switch').first().json.message }}",
                    "rightValue": "toggle"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "custom_function_1",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "af6d07f3-0ac2-4c05-8535-26d618892b8b",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('MQTT Trigger - Ikea Remote Switch').first().json.message }}",
                    "rightValue": "brightness_up_hold"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "custom_function_2",
              "conditions": {
                "options": {
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "a5e8ce30-4b18-450a-8b15-342a698fec61",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('MQTT Trigger - Ikea Remote Switch').first().json.message }}",
                    "rightValue": "brightness_down_hold"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "4a9ddd4d-ae2d-43c8-b3fd-70a2b15c5743",
      "name": "Custom Function 2 - P1",
      "type": "n8n-nodes-base.spotify",
      "position": [
        840,
        1020
      ],
      "parameters": {
        "resource": "playlist",
        "operation": "getUserPlaylists",
        "returnAll": true
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "29f842ad-f7cb-47b5-81fe-349f193e54bb",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        1040,
        1020
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "f7b6844a-ad78-4f29-801b-cef817a42e94",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.name }}",
              "rightValue": "={{ $('Globals').first().json.favorite_playlist_name }}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "cb038583-e930-4fee-9166-fa182d20868e",
      "name": "Globals",
      "type": "n8n-nodes-base.set",
      "position": [
        -100,
        160
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "2124b4d2-f929-459d-b285-3ac18df3ab60",
              "name": "target_spotify_playback_device_name",
              "type": "string",
              "value": "My Smart-Speaker Playback Device"
            },
            {
              "id": "b7f0468d-c5c3-4424-8db8-af823a10c7f0",
              "name": "favorite_playlist_name",
              "type": "string",
              "value": "Discover Weekly"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f4505b9a-6f04-4ff7-9384-05bae95b2fc8",
      "name": "Custom Function 2 - P3",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1260,
        1020
      ],
      "parameters": {
        "id": "=spotify:playlist:{{ $json.id }}",
        "operation": "startMusic"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2b2a81f9-69b6-42ca-accc-d4d987d6823c",
      "name": "Oops. How was this reached?",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1080,
        680
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "e45f04d6-bb3c-4580-9ef4-307d3692ad29",
      "name": "Spotify API - Get Device Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        440,
        260
      ],
      "parameters": {
        "url": "https://api.spotify.com/v1/me/player",
        "options": {},
        "sendQuery": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "device_id",
              "value": "={{ $('Globals').first().json.target_spotify_playback_device_id }}"
            }
          ]
        },
        "nodeCredentialType": "spotifyOAuth2Api"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 4.1,
      "alwaysOutputData": true
    },
    {
      "id": "ffa38f10-f9b4-4a52-954e-39adcd924633",
      "name": "Already playing on Target Device?",
      "type": "n8n-nodes-base.if",
      "position": [
        640,
        300
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "92d0f5fc-0743-4ea7-aad3-c8b72481bb97",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $('Spotify API - Get Device Status').first().json.device.name }}",
              "rightValue": "={{ $('Globals').first().json.target_spotify_playback_device_name }}"
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "f92ed1ea-c9a7-4818-9a8e-a5fa460177ea",
      "name": "Is Playing?",
      "type": "n8n-nodes-base.if",
      "position": [
        1140,
        520
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "caa4edf5-6436-4416-92f7-febd63cd47c5",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              },
              "leftValue": "={{ $('Spotify API - Get Device Status').first().json.is_playing && !$('Spotify API - Activate Target Playback Device').isExecuted }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "5580215d-0f20-4349-a7c2-b74f0e01080e",
      "name": "Spotify Prev",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1300,
        -200
      ],
      "parameters": {
        "operation": "previousSong"
      },
      "credentials": {
        "spotifyOAuth2Api": {
          "id": "4AquI6TQMHILfmvx",
          "name": "Spotify App Credentials"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f3babdeb-86d4-4dc6-85a4-95c48f4f07ef",
      "name": "MQTT Trigger - Remote Switch",
      "type": "n8n-nodes-base.mqttTrigger",
      "position": [
        -280,
        160
      ],
      "parameters": {
        "topics": "zigbee2mqtt/MyIOTButton1234/action",
        "options": {
          "jsonParseBody": true
        }
      },
      "credentials": {
        "mqtt": {
          "id": "65ppR4lt7hVNzfVG",
          "name": "MQTT account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "0c1bd86f-49f7-4505-9c8a-047dcb10a1bd",
      "name": "Remote Action -> Function Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        100,
        140
      ],
      "parameters": {
        "rules": {
          "rules": [
            {
              "value2": "arrow_left_click",
              "outputKey": "left"
            },
            {
              "value2": "arrow_right_click",
              "outputKey": "right"
            },
            {
              "value2": "brightness_up_click",
              "outputKey": "up"
            },
            {
              "value2": "brightness_down_click",
              "outputKey": "down"
            },
            {
              "value2": "toggle",
              "outputKey": "on_off"
            },
            {
              "value2": "brightness_up_hold",
              "outputKey": "custom_function_1"
            },
            {
              "value2": "brightness_down_hold",
              "outputKey": "custom_function_2"
            }
          ]
        },
        "value1": "={{ $('MQTT Trigger - Ikea Remote Switch').first().json.message }}",
        "dataType": "string"
      },
      "typeVersion": 2
    }
  ],
  "connections": {
    "Filter": {
      "main": [
        [
          {
            "node": "Custom Function 2 - P3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Globals": {
      "main": [
        [
          {
            "node": "Remote Action -> Function Router",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Playing?": {
      "main": [
        [
          {
            "node": "Spotify Pause",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Spotify Resume",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Custom Function 1 - P1": {
      "main": [
        [
          {
            "node": "Custom Function 2 - P2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Custom Function 2 - P1": {
      "main": [
        [
          {
            "node": "Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Custom Function 2 - P2": {
      "main": [
        [
          {
            "node": "Custom Function 1 - P3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Individual Devices": {
      "main": [
        [
          {
            "node": "Select Device by Name to get device_id",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route to Requested Function": {
      "main": [
        [
          {
            "node": "Spotify API - Volume up 5pct",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Spotify API - Volume down 5pct",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Is Playing?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Custom Function 1 - P1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Custom Function 2 - P1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Oops. How was this reached?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spotify API - Get Device Status": {
      "main": [
        [
          {
            "node": "Already playing on Target Device?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Remote Action -> Function Router": {
      "main": [
        [
          {
            "node": "Spotify Prev",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Spotify Next",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Spotify API - Get Device Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Spotify API - Get Device Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Spotify API - Get Device Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Spotify API - Get Device Status",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Spotify API - Get Device Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Already playing on Target Device?": {
      "main": [
        [
          {
            "node": "Route to Requested Function",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Spotify API - Get Available Devices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "MQTT Trigger - Ikea Remote Switch": {
      "main": [
        [
          {
            "node": "Globals",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spotify API - Get Available Devices": {
      "main": [
        [
          {
            "node": "Extract Individual Devices",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Select Device by Name to get device_id": {
      "main": [
        [
          {
            "node": "Spotify API - Activate Target Playback Device",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Spotify API - Activate Target Playback Device": {
      "main": [
        [
          {
            "node": "Route to Requested Function",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Actions

Share
Categories:
Tags:
ifnoopsethttprequestswitchstickynotesplitoutfilterspotifymqtttrigger

Technical Specs

Complexity:
Expert
Node Count:
26 nodes
Published:11 months ago
Updated:4 days ago

Compatibility

Platform:
N8N Cloud & Self-hosted
Min Version:
N8N v1.0.0+
Supports cloud and self-hosted deployment

License

This workflow template follows MIT license, you can freely use, modify and distribute.

Please comply with relevant third-party service terms when using.

Related Workflows