[
  {
    "id": "503d4505e4a78f4f",
    "type": "group",
    "style": {
      "stroke": "#999999",
      "stroke-opacity": "1",
      "fill": "none",
      "fill-opacity": "1",
      "label": true,
      "label-position": "nw",
      "color": "#a4a4a4"
    },
    "nodes": [
      "inject_on",
      "inject_off",
      "e63feb98ac62ced9",
      "1f97eb9f022ca167",
      "function_toggle",
      "inject_toggle",
      "comment_new_logic",
      "f1a21e9281776456",
      "22958b10dcb7ca8c",
      "16c1c011a6b648c8",
      "6717f2131d1435fd",
      "266858152330e426"
    ],
    "x": 184,
    "y": 319,
    "w": 842,
    "h": 322
  },
  {
    "id": "inject_on",
    "type": "inject",
    "g": "503d4505e4a78f4f",
    "name": "ON",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": "0",
    "topic": "",
    "payload": "true",
    "payloadType": "bool",
    "x": 310,
    "y": 400,
    "wires": [
      [
        "f1a21e9281776456"
      ]
    ]
  },
  {
    "id": "inject_off",
    "type": "inject",
    "g": "503d4505e4a78f4f",
    "name": "OFF",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": "0",
    "topic": "",
    "payload": "false",
    "payloadType": "bool",
    "x": 310,
    "y": 440,
    "wires": [
      [
        "f1a21e9281776456"
      ]
    ]
  },
  {
    "id": "e63feb98ac62ced9",
    "type": "debug",
    "g": "503d4505e4a78f4f",
    "name": "2 · Feedback",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 870,
    "y": 580,
    "wires": []
  },
  {
    "id": "1f97eb9f022ca167",
    "type": "debug",
    "g": "503d4505e4a78f4f",
    "name": "1 · Switch On/OFF",
    "active": true,
    "tosidebar": true,
    "console": false,
    "tostatus": false,
    "complete": "payload",
    "targetType": "msg",
    "statusVal": "",
    "statusType": "auto",
    "x": 890,
    "y": 540,
    "wires": []
  },
  {
    "id": "function_toggle",
    "type": "function",
    "g": "503d4505e4a78f4f",
    "name": "Smart Toggle",
    "func": "// Toggle logic using context to remember state\nlet currentState = context.get('switchState') || false;\nlet newState = !currentState;\n\n// Save the new state\ncontext.set('switchState', newState);\n\n// Create message with communication object\nmsg.inputTarget = \"Switch On/OFF\";\nmsg.payload = newState;\n\nnode.status({\n    fill: newState ? \"green\" : \"red\",\n    shape: \"dot\", \n    text: newState ? \"ON\" : \"OFF\"\n});\n\nreturn msg;",
    "outputs": 1,
    "timeout": 0,
    "noerr": 0,
    "initialize": "",
    "finalize": "",
    "libs": [],
    "x": 490,
    "y": 600,
    "wires": [
      [
        "22958b10dcb7ca8c"
      ]
    ]
  },
  {
    "id": "inject_toggle",
    "type": "inject",
    "g": "503d4505e4a78f4f",
    "name": "Toggle Switch",
    "props": [],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": "0",
    "topic": "",
    "x": 300,
    "y": 600,
    "wires": [
      [
        "function_toggle"
      ]
    ]
  },
  {
    "id": "comment_new_logic",
    "type": "comment",
    "g": "503d4505e4a78f4f",
    "name": "Communication Light Switch",
    "info": "## Light Switch node\nDevice: double-click the device node and choose the device of your installation, then Deploy.\n\n### Input targets\n- `Switch On/OFF` — command, true / false\n- `Feedback` — status, true / false\n\n### Outputs\n1. Switch On/OFF (command)\n2. Feedback (feedback)\n\n### Rules (node-red-cgen-widget-nodes 1.15)\n- `msg.inputTarget` must match a name above exactly (case-sensitive). Use an **Input Target** node to pick it from a list. A message with a missing or unknown target is ignored.\n- A message from the flow is sent to the server and also leaves on the output of the same name.\n- Outputs also fire when the device changes elsewhere: a **command** output when the app, a scenario, an automation or another flow commands it (only when the value changes), a **feedback** output each time the device reports a value.\n- Writing a feedback / status target updates the value HyperVisu shows; nothing is sent to the device. Use it with VIRTUAL devices.",
    "x": 370,
    "y": 360,
    "wires": []
  },
  {
    "id": "f1a21e9281776456",
    "type": "hypervisu-input-target",
    "g": "503d4505e4a78f4f",
    "selectedWidget": "2",
    "selectedInput": "Switch On/OFF",
    "displayName": "Input Target",
    "x": 510,
    "y": 420,
    "wires": [
      [
        "22958b10dcb7ca8c"
      ]
    ]
  },
  {
    "id": "22958b10dcb7ca8c",
    "type": "widget-LightSwitch",
    "g": "503d4505e4a78f4f",
    "dropdownRoom": "",
    "dropdownCategory": "",
    "dropdownWidget": "",
    "displayName": "Light Switch (set device)",
    "x": 740,
    "y": 460,
    "wires": [
      [
        "1f97eb9f022ca167"
      ],
      [
        "e63feb98ac62ced9"
      ]
    ]
  },
  {
    "id": "16c1c011a6b648c8",
    "type": "hypervisu-input-target",
    "g": "503d4505e4a78f4f",
    "selectedWidget": "2",
    "selectedInput": "Feedback",
    "displayName": "Input Target",
    "x": 510,
    "y": 500,
    "wires": [
      [
        "22958b10dcb7ca8c"
      ]
    ]
  },
  {
    "id": "6717f2131d1435fd",
    "type": "inject",
    "g": "503d4505e4a78f4f",
    "name": "ON",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": "0",
    "topic": "",
    "payload": "true",
    "payloadType": "bool",
    "x": 310,
    "y": 480,
    "wires": [
      [
        "16c1c011a6b648c8"
      ]
    ]
  },
  {
    "id": "266858152330e426",
    "type": "inject",
    "g": "503d4505e4a78f4f",
    "name": "OFF",
    "props": [
      {
        "p": "payload"
      }
    ],
    "repeat": "",
    "crontab": "",
    "once": false,
    "onceDelay": "0",
    "topic": "",
    "payload": "false",
    "payloadType": "bool",
    "x": 310,
    "y": 520,
    "wires": [
      [
        "16c1c011a6b648c8"
      ]
    ]
  }
]