[
    {
        "id": "4f076cc7d4d8fd2b",
        "type": "tab",
        "label": "Room Lighting",
        "disabled": true,
        "info": "",
        "env": []
    },
    {
        "id": "3f0d17868bb6ca0a",
        "type": "junction",
        "z": "4f076cc7d4d8fd2b",
        "x": 1020,
        "y": 240,
        "wires": [
            [
                "82cc9370a140af9d",
                "a4393b6dd01f0ca6",
                "b5d44ef964cda53f",
                "848b24370f2cd4c6"
            ]
        ]
    },
    {
        "id": "d97727924dd8ccd6",
        "type": "junction",
        "z": "4f076cc7d4d8fd2b",
        "x": 1000,
        "y": 380,
        "wires": [
            [
                "8803c1607d67177b",
                "917760705ef510f0",
                "833e71965c225186",
                "5d7ddbdf4245fb4a"
            ]
        ]
    },
    {
        "id": "6159988dca3610b6",
        "type": "junction",
        "z": "4f076cc7d4d8fd2b",
        "x": 480,
        "y": 440,
        "wires": [
            [
                "e7ccdd71fa14353b",
                "8cf142255edb8fd7"
            ]
        ]
    },
    {
        "id": "6880e43fd5c2a514",
        "type": "junction",
        "z": "4f076cc7d4d8fd2b",
        "x": 360,
        "y": 360,
        "wires": [
            [
                "68ec20474b3e3c54",
                "4f3682cb9503bf0a",
                "969d1bf2ab3fcd66"
            ]
        ]
    },
    {
        "id": "e025c8e04a896c94",
        "type": "junction",
        "z": "4f076cc7d4d8fd2b",
        "x": 360,
        "y": 420,
        "wires": [
            [
                "6880e43fd5c2a514"
            ]
        ]
    },
    {
        "id": "373c2443f2ce14c9",
        "type": "junction",
        "z": "4f076cc7d4d8fd2b",
        "x": 600,
        "y": 200,
        "wires": [
            [
                "4f3682cb9503bf0a"
            ]
        ]
    },
    {
        "id": "18d9ab11ff39acf5",
        "type": "http in",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "url": "/relay/light/desk",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 470,
        "y": 160,
        "wires": [
            [
                "9535e7ba0cc358f2",
                "373c2443f2ce14c9"
            ]
        ]
    },
    {
        "id": "9535e7ba0cc358f2",
        "type": "http response",
        "z": "4f076cc7d4d8fd2b",
        "name": "response",
        "statusCode": "200",
        "headers": {
            "content-type": "text/plain"
        },
        "x": 720,
        "y": 160,
        "wires": []
    },
    {
        "id": "cdf4b4ae231f4743",
        "type": "switch",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 730,
        "y": 240,
        "wires": [
            [
                "c1c3d9834e84b512"
            ],
            [
                "c33faa6e546b79be"
            ]
        ]
    },
    {
        "id": "c1c3d9834e84b512",
        "type": "change",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "1",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "next",
                "pt": "flow",
                "to": "0",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 900,
        "y": 240,
        "wires": [
            [
                "3f0d17868bb6ca0a"
            ]
        ]
    },
    {
        "id": "c33faa6e546b79be",
        "type": "change",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "0",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "next",
                "pt": "flow",
                "to": "1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 840,
        "y": 300,
        "wires": [
            [
                "3f0d17868bb6ca0a"
            ]
        ]
    },
    {
        "id": "4f3682cb9503bf0a",
        "type": "function",
        "z": "4f076cc7d4d8fd2b",
        "name": "get next value",
        "func": "msg.payload = flow.get(\"next\")||0;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 300,
        "wires": [
            [
                "cdf4b4ae231f4743"
            ]
        ]
    },
    {
        "id": "8089bfe60bf4f1ef",
        "type": "inject",
        "z": "4f076cc7d4d8fd2b",
        "name": "Poke",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 330,
        "y": 240,
        "wires": [
            [
                "4f3682cb9503bf0a"
            ]
        ]
    },
    {
        "id": "6d7af614a4918e59",
        "type": "switch",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "0",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 710,
        "y": 380,
        "wires": [
            [
                "99e36066d2d381c6"
            ],
            [
                "459796e0de96a87b"
            ]
        ]
    },
    {
        "id": "99e36066d2d381c6",
        "type": "change",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "1",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "next",
                "pt": "flow",
                "to": "0",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 880,
        "y": 380,
        "wires": [
            [
                "d97727924dd8ccd6"
            ]
        ]
    },
    {
        "id": "459796e0de96a87b",
        "type": "change",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "0",
                "tot": "str"
            },
            {
                "t": "set",
                "p": "next",
                "pt": "flow",
                "to": "1",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 820,
        "y": 440,
        "wires": [
            [
                "d97727924dd8ccd6"
            ]
        ]
    },
    {
        "id": "8cf142255edb8fd7",
        "type": "function",
        "z": "4f076cc7d4d8fd2b",
        "name": "get next value",
        "func": "msg.payload = flow.get(\"next\")||0;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 600,
        "y": 440,
        "wires": [
            [
                "6d7af614a4918e59"
            ]
        ]
    },
    {
        "id": "24eea27b450bb076",
        "type": "inject",
        "z": "4f076cc7d4d8fd2b",
        "name": "Poke",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "1",
        "payloadType": "num",
        "x": 90,
        "y": 340,
        "wires": [
            [
                "6880e43fd5c2a514"
            ]
        ]
    },
    {
        "id": "e7ccdd71fa14353b",
        "type": "debug",
        "z": "4f076cc7d4d8fd2b",
        "name": "relay 1 input",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 590,
        "y": 480,
        "wires": []
    },
    {
        "id": "ec822f5aae6dde5f",
        "type": "debug",
        "z": "4f076cc7d4d8fd2b",
        "name": "relay 2 input",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 200,
        "wires": []
    },
    {
        "id": "96a8076c22fffe36",
        "type": "ui_button",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "group": "6d4f6188446c09bc",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": true,
        "label": "Relay 2",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "relay.left",
        "icon": "",
        "payload": "1",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 560,
        "y": 240,
        "wires": [
            [
                "4f3682cb9503bf0a"
            ]
        ]
    },
    {
        "id": "4b65e76ecb5c2f6d",
        "type": "ui_button",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "group": "7edde5b95a1ccdc8",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": true,
        "label": "Relay 1",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "relay.left",
        "icon": "",
        "payload": "1",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 80,
        "y": 380,
        "wires": [
            [
                "6880e43fd5c2a514"
            ]
        ]
    },
    {
        "id": "68ec20474b3e3c54",
        "type": "ui_button",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "group": "7edde5b95a1ccdc8",
        "order": 2,
        "width": 0,
        "height": 0,
        "passthru": true,
        "label": "Relay 1 Bed Only",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "relay.left",
        "icon": "",
        "payload": "1",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 510,
        "y": 380,
        "wires": [
            [
                "6159988dca3610b6"
            ]
        ]
    },
    {
        "id": "82cc9370a140af9d",
        "type": "ui_text",
        "z": "4f076cc7d4d8fd2b",
        "group": "6d4f6188446c09bc",
        "order": 1,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Relay 2 Status",
        "format": "{{msg.payload}}",
        "layout": "col-center",
        "className": "relay.right",
        "style": false,
        "font": "",
        "fontSize": "",
        "color": "#000000",
        "x": 1140,
        "y": 300,
        "wires": []
    },
    {
        "id": "8803c1607d67177b",
        "type": "ui_text",
        "z": "4f076cc7d4d8fd2b",
        "group": "7edde5b95a1ccdc8",
        "order": 1,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Relay 1 Status",
        "format": "{{msg.payload}}",
        "layout": "col-center",
        "className": "relay.right",
        "style": false,
        "font": "",
        "fontSize": "",
        "color": "#000000",
        "x": 1120,
        "y": 440,
        "wires": []
    },
    {
        "id": "a4393b6dd01f0ca6",
        "type": "rpi-gpio out",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "pin": "5",
        "set": true,
        "level": "0",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 1120,
        "y": 240,
        "wires": []
    },
    {
        "id": "917760705ef510f0",
        "type": "rpi-gpio out",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "pin": "6",
        "set": true,
        "level": "0",
        "freq": "",
        "out": "out",
        "bcm": true,
        "x": 1120,
        "y": 380,
        "wires": []
    },
    {
        "id": "b539232a3f04b2ae",
        "type": "rpi-gpio in",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "pin": "27",
        "intype": "up",
        "debounce": "25",
        "read": true,
        "bcm": true,
        "x": 80,
        "y": 420,
        "wires": [
            [
                "7ad9246330e2e3e8"
            ]
        ]
    },
    {
        "id": "cfcb495c5d6eba77",
        "type": "rpi-gpio in",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "pin": "22",
        "intype": "up",
        "debounce": "25",
        "read": true,
        "bcm": true,
        "x": 320,
        "y": 200,
        "wires": [
            [
                "9be7b712d9a3fee7"
            ]
        ]
    },
    {
        "id": "969d1bf2ab3fcd66",
        "type": "debug",
        "z": "4f076cc7d4d8fd2b",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 500,
        "y": 340,
        "wires": []
    },
    {
        "id": "7ad9246330e2e3e8",
        "type": "trigger",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "op1": "",
        "op2": "1",
        "op1type": "nul",
        "op2type": "payl",
        "duration": "250",
        "extend": false,
        "overrideDelay": true,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 2,
        "x": 240,
        "y": 420,
        "wires": [
            [
                "e025c8e04a896c94"
            ],
            [
                "e025c8e04a896c94"
            ]
        ]
    },
    {
        "id": "9be7b712d9a3fee7",
        "type": "trigger",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "op1": "",
        "op2": "1",
        "op1type": "nul",
        "op2type": "payl",
        "duration": "250",
        "extend": false,
        "overrideDelay": true,
        "units": "ms",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 2,
        "x": 480,
        "y": 200,
        "wires": [
            [
                "373c2443f2ce14c9"
            ],
            [
                "373c2443f2ce14c9"
            ]
        ]
    },
    {
        "id": "1cd8ba0534e4d6fd",
        "type": "http in",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "url": "/relay/light/bed",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 110,
        "y": 480,
        "wires": [
            [
                "6159988dca3610b6"
            ]
        ]
    },
    {
        "id": "60e11d6dddc55015",
        "type": "http response",
        "z": "4f076cc7d4d8fd2b",
        "name": "response",
        "statusCode": "200",
        "headers": {
            "content-type": "text/plain"
        },
        "x": 360,
        "y": 480,
        "wires": []
    },
    {
        "id": "1e19696c55bfe9fa",
        "type": "http in",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "url": "/relay/light/both",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 110,
        "y": 520,
        "wires": [
            [
                "6880e43fd5c2a514"
            ]
        ]
    },
    {
        "id": "b87d8a7a51917657",
        "type": "http response",
        "z": "4f076cc7d4d8fd2b",
        "name": "response",
        "statusCode": "200",
        "headers": {
            "content-type": "text/plain"
        },
        "x": 1260,
        "y": 500,
        "wires": []
    },
    {
        "id": "833e71965c225186",
        "type": "template",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "{{payload}}\n",
        "output": "str",
        "x": 1100,
        "y": 500,
        "wires": [
            [
                "b87d8a7a51917657"
            ]
        ]
    },
    {
        "id": "f8cfdf487d351f4c",
        "type": "http response",
        "z": "4f076cc7d4d8fd2b",
        "name": "response",
        "statusCode": "200",
        "headers": {
            "content-type": "text/plain"
        },
        "x": 1260,
        "y": 180,
        "wires": []
    },
    {
        "id": "b5d44ef964cda53f",
        "type": "template",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "{{payload}}\n",
        "output": "str",
        "x": 1100,
        "y": 180,
        "wires": [
            [
                "f8cfdf487d351f4c"
            ]
        ]
    },
    {
        "id": "848b24370f2cd4c6",
        "type": "mqtt out",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "topic": "nodered/desk/status",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "ba049e9b201fd897",
        "x": 1140,
        "y": 120,
        "wires": []
    },
    {
        "id": "5d7ddbdf4245fb4a",
        "type": "mqtt out",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "topic": "nodered/bed/status",
        "qos": "0",
        "retain": "false",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "ba049e9b201fd897",
        "x": 1130,
        "y": 560,
        "wires": []
    },
    {
        "id": "3dc6c6a6f827844d",
        "type": "mqtt in",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "topic": "nodered/bed/control",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "ba049e9b201fd897",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 110,
        "y": 300,
        "wires": [
            [
                "6880e43fd5c2a514"
            ]
        ]
    },
    {
        "id": "d092acdc2c921764",
        "type": "mqtt in",
        "z": "4f076cc7d4d8fd2b",
        "name": "",
        "topic": "nodered/desk/control",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "ba049e9b201fd897",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 480,
        "y": 120,
        "wires": [
            [
                "373c2443f2ce14c9"
            ]
        ]
    },
    {
        "id": "2147796069529ac4",
        "type": "ha-switch",
        "z": "4f076cc7d4d8fd2b",
        "name": "Bed Light",
        "version": 0,
        "debugenabled": false,
        "inputs": 0,
        "outputs": 2,
        "entityConfig": "793b2f3d8c1e6e25",
        "enableInput": false,
        "outputOnStateChange": false,
        "outputProperties": [
            {
                "property": "outputType",
                "propertyType": "msg",
                "value": "state change",
                "valueType": "str"
            },
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            }
        ],
        "x": 220,
        "y": 720,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "6d4f6188446c09bc",
        "type": "ui_group",
        "name": "Desk",
        "tab": "8c55911f6f8f3b31",
        "order": 2,
        "disp": true,
        "width": "9",
        "collapse": false,
        "className": ""
    },
    {
        "id": "7edde5b95a1ccdc8",
        "type": "ui_group",
        "name": "Bed",
        "tab": "8c55911f6f8f3b31",
        "order": 2,
        "disp": true,
        "width": "9",
        "collapse": false,
        "className": ""
    },
    {
        "id": "ba049e9b201fd897",
        "type": "mqtt-broker",
        "name": "",
        "broker": "homeassistant",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "793b2f3d8c1e6e25",
        "type": "ha-entity-config",
        "server": "27267a0051797862",
        "deviceConfig": "3648cea959bd53cb",
        "name": "Bed Light",
        "version": "6",
        "entityType": "switch",
        "haConfig": [
            {
                "property": "name",
                "value": "Bed Light"
            },
            {
                "property": "icon",
                "value": ""
            },
            {
                "property": "entity_picture",
                "value": ""
            },
            {
                "property": "entity_category",
                "value": "config"
            },
            {
                "property": "device_class",
                "value": "switch"
            }
        ],
        "resend": false,
        "debugEnabled": false
    },
    {
        "id": "8c55911f6f8f3b31",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    },
    {
        "id": "27267a0051797862",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    },
    {
        "id": "3648cea959bd53cb",
        "type": "ha-device-config",
        "name": "Raspberry Pi",
        "hwVersion": "1.0",
        "manufacturer": "Node-RED",
        "model": "Zero",
        "swVersion": "1.0"
    }
]