[
  {
    "id": "cdmqtttab01",
    "type": "tab",
    "label": "Custom Dashboard MQTT",
    "disabled": false,
    "info": "MQTT flow for the Waveshare Company/Custom Dashboard firmware. Default topics: esp32/di1..di8 and esp32/do1..do8. Payloads are plain UTF-8 strings 1 and 0. Use on a trusted private LAN only."
  },
  {
    "id": "cdaedes01",
    "type": "aedes broker",
    "z": "cdmqtttab01",
    "name": "Aedes MQTT broker (port 1883)",
    "mqtt_port": 1883,
    "mqtt_ws_bind": "port",
    "mqtt_ws_port": "",
    "mqtt_ws_path": "",
    "cert": "",
    "key": "",
    "ca": "",
    "certname": "",
    "keyname": "",
    "caname": "",
    "persistence_bind": "memory",
    "dburl": "",
    "persist_to_file": false,
    "usetls": false,
    "x": 220,
    "y": 75,
    "wires": [
      [],
      []
    ]
  },
  {
    "id": "cdaedesnote1",
    "type": "comment",
    "z": "cdmqtttab01",
    "name": "Aedes broker starts when you Deploy",
    "info": "This flow includes its own Aedes broker listening on TCP port 1883. Install node-red-contrib-aedes first if Node-RED reports a missing node. Do not run another broker (Aedes or Mosquitto) on port 1883 at the same time. After importing, edit the shared MQTT server configuration used by the MQTT In/Out nodes: the broker address 192.168.1.100 is only an example placeholder; it does not detect your PC IP. Run ipconfig, find IPv4 Address under the active Wi-Fi/Ethernet adapter (not Default Gateway), then replace the placeholder in the shared MQTT server configuration using the pencil icon beside Server in any MQTT In/Out node. Keep port 1883. The Node-RED editor is opened at localhost:1880, but MQTT clients use the PC LAN IPv4:1883. The Waveshare and MQTT Explorer use that same LAN address. The current dashboard firmware connects without MQTT username/password, so use only a trusted private LAN and do not port-forward the broker.",
    "x": 245,
    "y": 125,
    "wires": []
  },
  {
    "id": "cdbroker01",
    "type": "mqtt-broker",
    "name": "PC LAN IPv4 - replace example IP",
    "broker": "192.168.1.100",
    "port": "1883",
    "clientid": "node-red-custom-dashboard",
    "autoConnect": true,
    "usetls": false,
    "protocolVersion": "4",
    "keepalive": "60",
    "cleansession": true,
    "birthTopic": "",
    "birthQos": "0",
    "birthPayload": "",
    "closeTopic": "",
    "closeQos": "0",
    "closePayload": "",
    "willTopic": "",
    "willQos": "0",
    "willPayload": ""
  },
  {
    "id": "cdcomment01",
    "type": "comment",
    "z": "cdmqtttab01",
    "name": "1. Broker setup",
    "info": "Aedes runs on this PC on TCP port 1883. Set the shared MQTT server configuration for all MQTT In/Out nodes to the PC LAN IPv4 address (example: 192.168.1.100), not localhost. The Node-RED editor itself remains at http://localhost:1880. The Waveshare, MQTT Explorer and Node-RED MQTT nodes must all target the same PC LAN IPv4 address and port 1883. Use only one broker on this port. The installed Custom Dashboard connects without MQTT credentials; use a trusted private LAN. IMPORTANT: 192.168.1.100 is an example only. The flow cannot detect the importing user's PC IP. Replace it with the PC LAN IPv4 from ipconfig before Deploy.",
    "x": 180,
    "y": 150,
    "wires": []
  },
  {
    "id": "cdcomment02",
    "type": "comment",
    "z": "cdmqtttab01",
    "name": "2. Control the 8 digital outputs",
    "info": "Each ON/OFF Inject publishes a UTF-8 string (not JSON) to esp32/doN. Retain is disabled so old ON commands are not replayed when a device reconnects.",
    "x": 230,
    "y": 190,
    "wires": []
  },
  {
    "id": "cdcomment03",
    "type": "comment",
    "z": "cdmqtttab01",
    "name": "3. Monitor DI and DO states",
    "info": "DI messages come from the board. DO topic messages may be the commands from Node-RED itself, not independent output feedback. Verify actual board dashboard state. For a board-originated heartbeat test, set DI1 Pub ms to 1000 in IoT Config.",
    "x": 230,
    "y": 1000,
    "wires": []
  },
  {
    "id": "cdon01",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO1 ON",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "1",
    "payloadType": "str",
    "x": 150,
    "y": 230,
    "wires": [
      [
        "cdout01"
      ]
    ]
  },
  {
    "id": "cdoff01",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO1 OFF",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "0",
    "payloadType": "str",
    "x": 150,
    "y": 265,
    "wires": [
      [
        "cdout01"
      ]
    ]
  },
  {
    "id": "cdout01",
    "type": "mqtt out",
    "z": "cdmqtttab01",
    "name": "Command DO1",
    "topic": "esp32/do1",
    "qos": "0",
    "retain": "false",
    "respTopic": "",
    "contentType": "",
    "userProps": "",
    "correl": "",
    "expiry": "",
    "broker": "cdbroker01",
    "x": 430,
    "y": 247,
    "wires": []
  },
  {
    "id": "cdon02",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO2 ON",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "1",
    "payloadType": "str",
    "x": 150,
    "y": 312,
    "wires": [
      [
        "cdout02"
      ]
    ]
  },
  {
    "id": "cdoff02",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO2 OFF",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "0",
    "payloadType": "str",
    "x": 150,
    "y": 347,
    "wires": [
      [
        "cdout02"
      ]
    ]
  },
  {
    "id": "cdout02",
    "type": "mqtt out",
    "z": "cdmqtttab01",
    "name": "Command DO2",
    "topic": "esp32/do2",
    "qos": "0",
    "retain": "false",
    "respTopic": "",
    "contentType": "",
    "userProps": "",
    "correl": "",
    "expiry": "",
    "broker": "cdbroker01",
    "x": 430,
    "y": 329,
    "wires": []
  },
  {
    "id": "cdon03",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO3 ON",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "1",
    "payloadType": "str",
    "x": 150,
    "y": 394,
    "wires": [
      [
        "cdout03"
      ]
    ]
  },
  {
    "id": "cdoff03",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO3 OFF",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "0",
    "payloadType": "str",
    "x": 150,
    "y": 429,
    "wires": [
      [
        "cdout03"
      ]
    ]
  },
  {
    "id": "cdout03",
    "type": "mqtt out",
    "z": "cdmqtttab01",
    "name": "Command DO3",
    "topic": "esp32/do3",
    "qos": "0",
    "retain": "false",
    "respTopic": "",
    "contentType": "",
    "userProps": "",
    "correl": "",
    "expiry": "",
    "broker": "cdbroker01",
    "x": 430,
    "y": 411,
    "wires": []
  },
  {
    "id": "cdon04",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO4 ON",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "1",
    "payloadType": "str",
    "x": 150,
    "y": 476,
    "wires": [
      [
        "cdout04"
      ]
    ]
  },
  {
    "id": "cdoff04",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO4 OFF",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "0",
    "payloadType": "str",
    "x": 150,
    "y": 511,
    "wires": [
      [
        "cdout04"
      ]
    ]
  },
  {
    "id": "cdout04",
    "type": "mqtt out",
    "z": "cdmqtttab01",
    "name": "Command DO4",
    "topic": "esp32/do4",
    "qos": "0",
    "retain": "false",
    "respTopic": "",
    "contentType": "",
    "userProps": "",
    "correl": "",
    "expiry": "",
    "broker": "cdbroker01",
    "x": 430,
    "y": 493,
    "wires": []
  },
  {
    "id": "cdon05",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO5 ON",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "1",
    "payloadType": "str",
    "x": 150,
    "y": 558,
    "wires": [
      [
        "cdout05"
      ]
    ]
  },
  {
    "id": "cdoff05",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO5 OFF",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "0",
    "payloadType": "str",
    "x": 150,
    "y": 593,
    "wires": [
      [
        "cdout05"
      ]
    ]
  },
  {
    "id": "cdout05",
    "type": "mqtt out",
    "z": "cdmqtttab01",
    "name": "Command DO5",
    "topic": "esp32/do5",
    "qos": "0",
    "retain": "false",
    "respTopic": "",
    "contentType": "",
    "userProps": "",
    "correl": "",
    "expiry": "",
    "broker": "cdbroker01",
    "x": 430,
    "y": 575,
    "wires": []
  },
  {
    "id": "cdon06",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO6 ON",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "1",
    "payloadType": "str",
    "x": 150,
    "y": 640,
    "wires": [
      [
        "cdout06"
      ]
    ]
  },
  {
    "id": "cdoff06",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO6 OFF",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "0",
    "payloadType": "str",
    "x": 150,
    "y": 675,
    "wires": [
      [
        "cdout06"
      ]
    ]
  },
  {
    "id": "cdout06",
    "type": "mqtt out",
    "z": "cdmqtttab01",
    "name": "Command DO6",
    "topic": "esp32/do6",
    "qos": "0",
    "retain": "false",
    "respTopic": "",
    "contentType": "",
    "userProps": "",
    "correl": "",
    "expiry": "",
    "broker": "cdbroker01",
    "x": 430,
    "y": 657,
    "wires": []
  },
  {
    "id": "cdon07",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO7 ON",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "1",
    "payloadType": "str",
    "x": 150,
    "y": 722,
    "wires": [
      [
        "cdout07"
      ]
    ]
  },
  {
    "id": "cdoff07",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO7 OFF",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "0",
    "payloadType": "str",
    "x": 150,
    "y": 757,
    "wires": [
      [
        "cdout07"
      ]
    ]
  },
  {
    "id": "cdout07",
    "type": "mqtt out",
    "z": "cdmqtttab01",
    "name": "Command DO7",
    "topic": "esp32/do7",
    "qos": "0",
    "retain": "false",
    "respTopic": "",
    "contentType": "",
    "userProps": "",
    "correl": "",
    "expiry": "",
    "broker": "cdbroker01",
    "x": 430,
    "y": 739,
    "wires": []
  },
  {
    "id": "cdon08",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO8 ON",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "1",
    "payloadType": "str",
    "x": 150,
    "y": 804,
    "wires": [
      [
        "cdout08"
      ]
    ]
  },
  {
    "id": "cdoff08",
    "type": "inject",
    "z": "cdmqtttab01",
    "name": "DO8 OFF",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": 0.1,
    "topic": "",
    "payload": "0",
    "payloadType": "str",
    "x": 150,
    "y": 839,
    "wires": [
      [
        "cdout08"
      ]
    ]
  },
  {
    "id": "cdout08",
    "type": "mqtt out",
    "z": "cdmqtttab01",
    "name": "Command DO8",
    "topic": "esp32/do8",
    "qos": "0",
    "retain": "false",
    "respTopic": "",
    "contentType": "",
    "userProps": "",
    "correl": "",
    "expiry": "",
    "broker": "cdbroker01",
    "x": 430,
    "y": 821,
    "wires": []
  },
  {
    "id": "cdstatefmt01",
    "type": "function",
    "z": "cdmqtttab01",
    "name": "Format channel state",
    "func": "const raw = String(msg.payload).trim();\nconst state = raw === '1' ? 'ON' : raw === '0' ? 'OFF' : raw;\nmsg.payload = { topic: msg.topic, state: state, raw: raw };\nreturn msg;",
    "outputs": 1,
    "timeout": 0,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 470,
    "y": 1120,
    "wires": [
      [
        "cddebug01"
      ]
    ]
  },
  {
    "id": "cddebug01",
    "type": "debug",
    "z": "cdmqtttab01",
    "name": "Custom Dashboard channel messages",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 740,
    "y": 1120,
    "wires": []
  },
  {
    "id": "cddi01",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DI1 state",
    "topic": "esp32/di1",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1190,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddo01",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DO1 messages",
    "topic": "esp32/do1",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1219,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddi02",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DI2 state",
    "topic": "esp32/di2",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1248,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddo02",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DO2 messages",
    "topic": "esp32/do2",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1277,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddi03",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DI3 state",
    "topic": "esp32/di3",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1306,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddo03",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DO3 messages",
    "topic": "esp32/do3",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1335,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddi04",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DI4 state",
    "topic": "esp32/di4",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1364,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddo04",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DO4 messages",
    "topic": "esp32/do4",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1393,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddi05",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DI5 state",
    "topic": "esp32/di5",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1422,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddo05",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DO5 messages",
    "topic": "esp32/do5",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1451,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddi06",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DI6 state",
    "topic": "esp32/di6",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1480,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddo06",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DO6 messages",
    "topic": "esp32/do6",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1509,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddi07",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DI7 state",
    "topic": "esp32/di7",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1538,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddo07",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DO7 messages",
    "topic": "esp32/do7",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1567,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddi08",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DI8 state",
    "topic": "esp32/di8",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1596,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  },
  {
    "id": "cddo08",
    "type": "mqtt in",
    "z": "cdmqtttab01",
    "name": "DO8 messages",
    "topic": "esp32/do8",
    "qos": "0",
    "datatype": "utf8",
    "broker": "cdbroker01",
    "nl": false,
    "rap": true,
    "rh": 0,
    "inputs": 0,
    "x": 170,
    "y": 1625,
    "wires": [
      [
        "cdstatefmt01"
      ]
    ]
  }
]
