{
  "id": "01UHgh673YDyv5xN",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "IOT control via MQTT and webhook",
  "tags": [],
  "nodes": [
    {
      "id": "3d3b2e80-4e4e-43ec-b2fd-7000e7307915",
      "name": "MQTT Publish Topic Node",
      "type": "n8n-nodes-base.mqtt",
      "position": [
        680,
        -20
      ],
      "parameters": {
        "topic": "pin-control",
        "message": "={{ $json.pin }}",
        "options": {},
        "sendInputData": false
      },
      "credentials": {
        "mqtt": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f4444f19-424a-487b-8d7c-3c609a55b913",
      "name": "Set data for MQTT message payload",
      "type": "n8n-nodes-base.set",
      "position": [
        360,
        -20
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "pin",
              "value": "={{ $json.query.value }}"
            }
          ]
        },
        "options": {},
        "keepOnlySet": true
      },
      "typeVersion": 1
    },
    {
      "id": "3ed996b8-419f-458a-a717-b35e1a52a851",
      "name": "IOT control Webhook ",
      "type": "n8n-nodes-base.webhook",
      "position": [
        20,
        -20
      ],
      "parameters": {
        "path": "pin-control",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "40fa6c2a-c515-412b-93df-eceb993c38c9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        -160
      ],
      "parameters": {
        "height": 120,
        "content": "When the \"on\" or \"off\" button is clicked on the IOT control webpage the webhook gets the selected value and triggers the workflow "
      },
      "typeVersion": 1
    },
    {
      "id": "159f8c6e-285a-443a-bd9d-ae3456b9a6a8",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -140
      ],
      "parameters": {
        "height": 80,
        "content": "The set node prepares the receive data as a message payload for the MQTT topic"
      },
      "typeVersion": 1
    },
    {
      "id": "250140e6-f46c-42c2-b79a-537ec4975b97",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        -160
      ],
      "parameters": {
        "height": 100,
        "content": "Publishes MQTT topic \"pin-control\" with the payload data to control the GPIO on the ESP32 microcontroller"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f5d124a9-c6e1-44f5-b088-cafb8e5bd602",
  "connections": {
    "IOT control Webhook ": {
      "main": [
        [
          {
            "node": "Set data for MQTT message payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set data for MQTT message payload": {
      "main": [
        [
          {
            "node": "MQTT Publish Topic Node",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}