{
  "name": "IOT button remote / Spotify control integration with MQTT",
  "nodes": [
    {
      "id": "169e3a8c-82f5-4527-a187-27b8e5d903c1",
      "name": "Spotify Next",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1300,
        -40
      ]
    },
    {
      "id": "7840d6b8-7eb4-4ac2-8bd0-946561f7de38",
      "name": "Spotify Resume",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1300,
        660
      ]
    },
    {
      "id": "35e768a3-b648-4d5e-a6a4-fa5f5be3d922",
      "name": "Spotify Pause",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1300,
        480
      ]
    },
    {
      "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."
      }
    },
    {
      "id": "164e904f-278d-4e48-81de-e1fc050e683a",
      "name": "Spotify API - Volume up 5pct",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1300,
        120
      ]
    },
    {
      "id": "a75cfc9b-ba21-4771-a2ff-f7aee843f344",
      "name": "Spotify API - Volume down 5pct",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1300,
        300
      ]
    },
    {
      "id": "deae216d-aaaa-406c-b978-45b790c5d837",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -360,
        608.2274931489221
      ],
      "parameters": {
        "width": 906.3175117167951,
        "height": 278.70214810442735,
        "content": "### Find the target player device (or spotify device group) by name, and activate it."
      }
    },
    {
      "id": "2733fd1e-4c58-4f3e-bf7d-f4111fea6efc",
      "name": "Spotify API - Get Available Devices",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -260,
        680
      ]
    },
    {
      "id": "1d7fcab5-e49d-4d03-8e7d-aa339afa45ec",
      "name": "Extract Individual Devices",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        -60,
        680
      ]
    },
    {
      "id": "7ae0af1c-2fbb-47e4-b2ab-670be441d86f",
      "name": "Select Device by Name to get device_id",
      "type": "n8n-nodes-base.filter",
      "position": [
        140,
        680
      ]
    },
    {
      "id": "738d57fd-9dcb-4d3d-b070-73867c926d3f",
      "name": "Custom Function 1 - P1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        880,
        840
      ]
    },
    {
      "id": "e3fc6784-1612-427d-9b78-a3f4050ed176",
      "name": "Custom Function 2 - P2",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1080,
        840
      ]
    },
    {
      "id": "340f23ff-ae8a-4032-a641-30bc32af09c7",
      "name": "Custom Function 1 - P3",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1300,
        840
      ]
    },
    {
      "id": "30a413da-5ce3-44a9-a43e-c6679b712087",
      "name": "Spotify API - Activate Target Playback Device",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        360,
        680
      ]
    },
    {
      "id": "91dd48fe-6c3c-4170-8392-3d9885e61047",
      "name": "Route to Requested Function",
      "type": "n8n-nodes-base.switch",
      "position": [
        900,
        420
      ]
    },
    {
      "id": "4a9ddd4d-ae2d-43c8-b3fd-70a2b15c5743",
      "name": "Custom Function 2 - P1",
      "type": "n8n-nodes-base.spotify",
      "position": [
        840,
        1020
      ]
    },
    {
      "id": "29f842ad-f7cb-47b5-81fe-349f193e54bb",
      "name": "Filter",
      "type": "n8n-nodes-base.filter",
      "position": [
        1040,
        1020
      ]
    },
    {
      "id": "cb038583-e930-4fee-9166-fa182d20868e",
      "name": "Globals",
      "type": "n8n-nodes-base.set",
      "position": [
        -100,
        160
      ]
    },
    {
      "id": "f4505b9a-6f04-4ff7-9384-05bae95b2fc8",
      "name": "Custom Function 2 - P3",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1260,
        1020
      ]
    },
    {
      "id": "2b2a81f9-69b6-42ca-accc-d4d987d6823c",
      "name": "Oops. How was this reached?",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1080,
        680
      ]
    },
    {
      "id": "e45f04d6-bb3c-4580-9ef4-307d3692ad29",
      "name": "Spotify API - Get Device Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        440,
        260
      ]
    },
    {
      "id": "ffa38f10-f9b4-4a52-954e-39adcd924633",
      "name": "Already playing on Target Device?",
      "type": "n8n-nodes-base.if",
      "position": [
        640,
        300
      ]
    },
    {
      "id": "f92ed1ea-c9a7-4818-9a8e-a5fa460177ea",
      "name": "Is Playing?",
      "type": "n8n-nodes-base.if",
      "position": [
        1140,
        520
      ]
    },
    {
      "id": "5580215d-0f20-4349-a7c2-b74f0e01080e",
      "name": "Spotify Prev",
      "type": "n8n-nodes-base.spotify",
      "position": [
        1300,
        -200
      ]
    },
    {
      "id": "f3babdeb-86d4-4dc6-85a4-95c48f4f07ef",
      "name": "MQTT Trigger - Remote Switch",
      "type": "n8n-nodes-base.mqttTrigger",
      "position": [
        -280,
        160
      ]
    },
    {
      "id": "0c1bd86f-49f7-4505-9c8a-047dcb10a1bd",
      "name": "Remote Action -> Function Router",
      "type": "n8n-nodes-base.switch",
      "position": [
        100,
        140
      ]
    }
  ],
  "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
          }
        ]
      ]
    }
  }
}