HomeKit-Connected Garage Door Controller (with Waveshare Relay)

HomeKit-Connected Garage Door Controller (with Waveshare Relay)

This Node-RED flow integrates a garage door controller with Apple's HomeKit using a Waveshare Modbus PoE Ethernet Relay (B) board and the node-red-contrib-homekit-bridged module.

The flow provides bidirectional control and status reporting between HomeKit and the relay board using MQTT, without requiring any dashboard interface.


✅ Features

  • 🚪 Garage door logic with full state machine (OPENING, OPENED, CLOSING, CLOSED, STOPPED)
  • 🧠 Obstruction detection: stops motion if emergency button, IR barrier, or small side door is triggered
  • 🔘 Relay pulse triggering: simulates physical push button via Waveshare relay
  • 🏠 HomeKit integration via GarageDoorOpener service
  • 🚨 Emergency stop, infra-red safety, door lock, and light control as HomeKit accessories
  • 🧭 Auto-stop timeout if door stays in transition too long
  • 🧩 Modular structure with link nodes and MQTT message mapping

🔌 Requirements

  • Node-RED
  • node-red-contrib-homekit-bridged
  • MQTT broker
  • Waveshare Modbus PoE Relay board (8 relay + 8 input model)
  • Garage door opener that accepts contact closure
  • Optional: sensors for door open/close state, IR barrier, emergency stop, etc.

🛠️ Setup Notes

  • The Waveshare board publishes its state via MQTT (garage/input) and listens for commands on garage/output.
  • HomeKit events trigger relay pulses to simulate button press (relay1).
  • Internal state is tracked using global.set/get for consistent stateful logic.
  • Accessory metadata includes model, serial and firmware info for HomeKit.
  • Includes contact sensors for IR barrier, emergency stop, little door, indoor/outdoor lights, and more.

[{"id":"3b42aeaf229ce661","type":"tab","label":"Garage Door","disabled":false,"info":"","env":[]},{"id":"7698f88f795cda86","type":"group","z":"3b42aeaf229ce661","name":"Initialize state","style":{"label":true},"nodes":["7dbb0eea1aac665e","1a8f7328929e76af","dc22bab23c29f3f8","66619a78f32df678","3661a1b5c607efd4","6ff4a913e06b6945","f0513ac32324e938","e789bccd8abd5183","59e7ec3be90c0020","d006c9059497f061","40cb9d5703b2dc2b","4f039876850134ec","05195e86fea7d88f","98fa6b739bf06a8e","4a4a523bdc3a372b","51d466375f4bc17a","1cb950783120399a","ce9adfee627055aa","54da1a1cc926dd8d","4201a49492e7041d"],"x":74,"y":99,"w":852,"h":362},{"id":"e4ed7c71cf9a620f","type":"group","z":"3b42aeaf229ce661","name":"Emergency Stop Button","style":{"label":true},"nodes":["962dd54dd2e0bc35","b19fcaf25a3a59d2","e67ac3b2ab26e60c","4ff472238317d4e1","f3d35e1cbefb017e","46fd79eeac7bc75b"],"x":74,"y":619,"w":1132,"h":142},{"id":"a3e903d9aed2aed7","type":"group","z":"3b42aeaf229ce661","name":"Little Garage Door","style":{"label":true},"nodes":["3657e9ceb9de4dce","d9bb436344d11c3a","6eb2a55d31759476","f19011e79ba140eb","efaeb28358de1b51","ea12178801ea78c2"],"x":74,"y":779,"w":972,"h":142},{"id":"769e7ecc5f4eabec","type":"group","z":"3b42aeaf229ce661","name":"Indoor Light","style":{"label":true},"nodes":["ed2d8340.e1d5d8","5844674e.178708","02d2c0368a0e3400","fd3f039dd691cab6","5ef517486e12d57c","62f9649fb495e6a1","2bf384d97786d143","29c023cb57f1cf18"],"x":74,"y":1099,"w":1172,"h":162},{"id":"fbb4904628975a0a","type":"group","z":"3b42aeaf229ce661","name":"Waveshare MQTT to NRCHKB adapter","style":{"label":true},"nodes":["bc43bcc553f776c3","e5faa778c0c39279","19bab88f237c34a5","dfc95a9d3bfa6dc2","424c61e1b3530e15","d1ea3faee897d6b8","160471fa64228dab","092a6b75ae013772","2d4c86cf01e34d92","6f8768a7fd08d9f2","6da23ccaf8d241cb","e8ccd317ba04b486","76ad87f578a379ac","d689a7ddd38107ba","24a562edd40954ab","b70e551b563c3de4","7adcf13825566ef4","8e71cfbac3e945c8","2c30499c89fa632e","785aeb83d47556a2","5c9246a536f37021","20ebe15b435a83af"],"x":1054,"y":99,"w":872,"h":482},{"id":"33ab9ca887a729a8","type":"group","z":"3b42aeaf229ce661","name":"Device Offline/Online (MQTT Will)","style":{"label":true},"nodes":["32772f384b19ad28","d41409253ef8b425","9d6af6b1453acf0c","8562b9f9b47ab024","fe0e75de915f6970"],"x":74,"y":479,"w":952,"h":122},{"id":"43ecc239f4b3542b","type":"group","z":"3b42aeaf229ce661","name":"Infra-red barrier","style":{"label":true},"nodes":["2568f7348e3bac5a","0c0397d5d344d4b0","2affbc33ca2236ce","6a2ca2a021420e88","c2ac3c84ef273531","324cf61755b8246d"],"x":74,"y":939,"w":1012,"h":142},{"id":"53313074be779929","type":"group","z":"3b42aeaf229ce661","name":"Homekit","style":{"label":true},"nodes":["fcde54d08e4958a1","5d703c7599061460","aacb2ed196ebb624","a74f0ea6e2c2a3ba","0c941d6022c5cd0b","84df0d7b671032d3","214aa6b997fd88cb","b38a9662ee994302","fb17222e9b2660be","5e957c2c15048aa2","40c5cb84079acd30","86879630fe7113c6","4be301efb35a4e61","0c262014455895e3","1028df9240903fab"],"x":74,"y":1839,"w":1632,"h":202},{"id":"eb7b1e230cf240ab","type":"group","z":"3b42aeaf229ce661","name":"Outdoor Light","style":{"label":true},"nodes":["37ef3f7079df26e8","19467429314cc3d9","0b0aa5ea40cb700a","f3a5b6652db8055e","1a7f00030aa8daf5","e5985853a1703320","07c6f643cea4f359","0fdf1343ba735e2c"],"x":74,"y":1279,"w":1272,"h":162},{"id":"66bf72d212597ab4","type":"group","z":"3b42aeaf229ce661","name":"Enable Infra-Red","style":{"label":true},"nodes":["e84612d08248611d","28283fb91169bac1","b1a7e61cc43047c3","b03cf7694e582cdc","22b0b5d79b253db8","7ad13ab28edb82f2","e9d9b263191322f3","422f1a0d1af953ad"],"x":74,"y":1459,"w":1172,"h":162},{"id":"f22e669b997c5e7f","type":"group","z":"3b42aeaf229ce661","name":"Lock Garage Door","style":{"label":true},"nodes":["484395482651c352","5b52a4711b519645","8fa3d9fdb7735196","d5ee565252a16e03","6e906578d943deaf","a78167ede44888f8","1769f9eae48a5483","d70866a75634525c"],"x":74,"y":1639,"w":1232,"h":162},{"id":"996359e1f0aa7d21","type":"mqtt in","z":"3b42aeaf229ce661","name":"","topic":"garage/#","qos":"1","datatype":"auto-detect","broker":"a6979323.bc6368","nl":false,"rap":true,"rh":0,"inputs":0,"x":180,"y":40,"wires":[["6c19c96e54d232cb"]]},{"id":"6c19c96e54d232cb","type":"debug","z":"3b42aeaf229ce661","name":"debug 5","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":340,"y":40,"wires":[]},{"id":"bc43bcc553f776c3","type":"mqtt in","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","topic":"garage/input","qos":"1","datatype":"auto-detect","broker":"a6979323.bc6368","nl":false,"rap":true,"rh":0,"inputs":0,"x":1150,"y":280,"wires":[["e5faa778c0c39279"]]},{"id":"e5faa778c0c39279","type":"function","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"Input Mapping","func":"var payload = msg.payload;\nif (typeof payload === \"string\" && payload.trim().length === 0) {\n    return null; // Ignore empty msg\n}\n\nif (payload.status != \"online\") {\n    return null; // Ignore offline device\n}\n\n\n// Inputs\nvar InfraredSwitch = payload.input1 == 1; // (1 because NC)\nvar ClosedSwitch = payload.input2 == 1; // (1 because NC)\nvar LittleDoorSwitch = payload.input3 == 1; // (1 because NO and closed = switch pushed)\nvar OpenedSwitch = payload.input4 == 0; // (0 because NO)\n// var OutdoorLightToggleSwitch = payload.input5 == 1; // Not used in NodeRed, only for linked mode in Waveshare\n// var IndoorLightToggleButton = payload.input6 == 1; // Not used in NodeRed\nvar EmergencyButton = payload.input7 == 0;\nvar LightDetectionRelay = payload.input8 == 1;\n\n// Output (relays states)\n// var Motor = payload.relay1 == 1; // Not used in NodeRed\n// var RedLight = payload.relay2 == 1; // Not used in NodeRed, only for linked mode in Waveshare\nvar DisableIR = payload.relay3 == 1; // Disable Infra-Red\n// var NotOpened = payload.relay4 == 1; // Not used in NodeRed, only for linked mode in Waveshare\nvar OutdoorLightRelay = payload.relay5 == 1; // Used in NodeRed to know the light state from toggle input\nvar IndoorLightRelay = payload.relay6 == 1; // Used in NodeRed to toggle relay\nvar GDoorLock = payload.relay7 == 1; // Lock Garage Door\n// var IndoorLightIndicator = payload.relay8 == 1; // Not used in NodeRed, only for linked mode in Waveshare\n\nvar Waveshare = {};\nWaveshare.InfraredSwitch = InfraredSwitch;\nWaveshare.ClosedSwitch = ClosedSwitch;\nWaveshare.LittleDoorSwitch = LittleDoorSwitch;\nWaveshare.OpenedSwitch = OpenedSwitch;\nWaveshare.EmergencyButton = EmergencyButton;\n\nvar IndoorLight = {};\nIndoorLight.LightDetectionRelay = LightDetectionRelay;\nIndoorLight.IndoorLightRelay = IndoorLightRelay;\nglobal.set(\"IndoorLight\", IndoorLight);\n\nreturn [\n    { \"payload\": payload.input7 == 0 }, // Emergency Button\n    { \"payload\": LittleDoorSwitch }, // Little Door Switch\n    { \"payload\": InfraredSwitch }, // Infrared Switch\n    { \"payload\": LightDetectionRelay }, // Indoor Light\n    { \"payload\": OutdoorLightRelay }, // Outdoor Light\n    { \"payload\": DisableIR }, // Enable IR\n    { \"payload\": GDoorLock }, // Lock Garage Door\n    { \"payload\": Waveshare } // Garage Door\n];","outputs":8,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1360,"y":280,"wires":[["092a6b75ae013772"],["20ebe15b435a83af"],["5c9246a536f37021"],["785aeb83d47556a2"],["2c30499c89fa632e"],["8e71cfbac3e945c8"],["7adcf13825566ef4"],["b70e551b563c3de4"]]},{"id":"fcde54d08e4958a1","type":"homekit-service","z":"3b42aeaf229ce661","g":"53313074be779929","isParent":true,"hostType":"0","bridge":"47c329efdf14f98b","accessoryId":"","parentService":"","name":"Porte de Garage","serviceName":"GarageDoorOpener","topic":"","filter":false,"manufacturer":"Nicolas Lambert","model":"Waveshare Modbus PoE Ethernet Relay (B)","serialNo":"1234567890","firmwareRev":"1","hardwareRev":"1","softwareRev":"1","cameraConfigVideoProcessor":"","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":"","cameraConfigMaxWidth":"","cameraConfigMaxHeight":"","cameraConfigMaxFPS":"","cameraConfigMaxBitrate":"","cameraConfigVideoCodec":"","cameraConfigAudioCodec":"","cameraConfigAudio":false,"cameraConfigPacketSize":"","cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"","cameraConfigMapAudio":"","cameraConfigVideoFilter":"","cameraConfigAdditionalCommandLine":"","cameraConfigDebug":false,"cameraConfigInterfaceName":"","characteristicProperties":"{\"CurrentDoorState\":1}","waitForSetupMsg":false,"outputs":2,"adaptiveLightingOptionsEnable":false,"adaptiveLightingOptionsCustomTemperatureAdjustment":"","x":1180,"y":1940,"wires":[["5d703c7599061460","fb17222e9b2660be"],["5e957c2c15048aa2"]]},{"id":"5d703c7599061460","type":"function","z":"3b42aeaf229ce661","g":"53313074be779929","name":"Main Logic","func":"if (msg.hap.session) { // Do stuff if it's from HomeKit\n    var GarageDoor = global.get(\"GarageDoor\");\n    var command = null;\n\n    if (msg.payload.TargetDoorState === 1) {\n        if (GarageDoor.CurrentState === \"OPENED\") {\n            // Normal close command\n            if (!GarageDoor.Obstruction) {\n                // Close if no obstruction\n                node.warn(\"CLOSING...\");\n                GarageDoor.CurrentState = \"CLOSING\";\n                command = {};\n            } else {\n                // Do not close if obstruction detected\n                node.warn(\"Obstruction! Clear the door area!\");\n            }\n        } else if (GarageDoor.CurrentState === \"OPENING\") {\n            // Stop door while opening\n            node.warn(\"STOPPING...\");\n            GarageDoor.LastState = \"STOPPED\";\n            GarageDoor.CurrentState = \"STOPPED\";\n            command = {};\n        } else if (GarageDoor.CurrentState === \"STOPPED\") {\n            // Restart door from stopped\n            if (!GarageDoor.Obstruction) {\n                // Close if no obstruction\n                node.warn(\"CLOSING...\");\n                GarageDoor.LastState = \"OPENED\"\n                GarageDoor.CurrentState = \"CLOSING\";\n                command = {};\n            } else {\n                // Do not close if obstruction detected\n                node.warn(\"Obstruction! Clear the door area!\");\n            }\n        }\n    } else if (msg.payload.TargetDoorState === 0) {\n        if (GarageDoor.CurrentState === \"CLOSED\") {\n            // Normal open command\n            node.warn(\"OPENING...\");\n            // GarageDoor.LastState = \"CLOSED\";\n            GarageDoor.CurrentState = \"OPENING\";\n            command = {};\n        } else if (GarageDoor.CurrentState === \"CLOSING\") {\n            // Stop door while closing\n            node.warn(\"STOPPING...\");\n            GarageDoor.LastState = \"STOPPED\";\n            GarageDoor.CurrentState = \"STOPPED\";\n            command = {};\n        } else if (GarageDoor.CurrentState === \"STOPPED\") {\n            // Restart door from stopped, assume it's going to close.\n            if (!GarageDoor.Obstruction) {\n                // Close if no obstruction\n                node.warn(\"CLOSING...\");\n                GarageDoor.LastState = \"OPENED\"\n                GarageDoor.CurrentState = \"CLOSING\";\n                command = {};\n            } else {\n                // Do not close if obstruction detected\n                node.warn(\"Obstruction! Clear the door area!\");\n            }\n        }\n    }\n\n    global.set(\"GarageDoor\", GarageDoor);\n\n    return [command, { \"payload\": GarageDoor }]\n}","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1410,"y":1900,"wires":[["4be301efb35a4e61"],["84df0d7b671032d3"]]},{"id":"aacb2ed196ebb624","type":"function","z":"3b42aeaf229ce661","g":"53313074be779929","name":"State Handler","func":"var GarageDoor = global.get(\"GarageDoor\") || {}; // load \"GarageDoor\" or set to empty\n\nif (msg.payload.OpenedSwitch && !msg.payload.ClosedSwitch) {\n    // The door is fully opened\n    GarageDoor.LastState = \"OPENED\";\n    GarageDoor.CurrentState = \"OPENED\";\n}\n\nif (!msg.payload.OpenedSwitch && msg.payload.ClosedSwitch) {\n    // The door is fully closed\n    GarageDoor.LastState = \"CLOSED\";\n    GarageDoor.CurrentState = \"CLOSED\";\n}\n\nif (!msg.payload.OpenedSwitch && !msg.payload.ClosedSwitch) {\n    // The door is in the middle\n    if (GarageDoor.LastState == \"OPENED\") GarageDoor.CurrentState = \"CLOSING\";\n    if (GarageDoor.LastState == \"CLOSED\") GarageDoor.CurrentState = \"OPENING\";\n    if (GarageDoor.LastState == \"STOPPED\") GarageDoor.CurrentState = \"STOPPED\";\n}\n\nGarageDoor.Obstruction = msg.payload.InfraredSwitch || msg.payload.EmergencyButton || msg.payload.LittleDoorSwitch;\n\nglobal.set(\"GarageDoor\", GarageDoor);\n\nvar out = { \"payload\": GarageDoor };\nvar reset = { \"reset\": true };\n\nif (GarageDoor.CurrentState == \"STOPPED\" || GarageDoor.CurrentState == \"OPENED\" || GarageDoor.CurrentState == \"CLOSED\") {\n    return [out, reset];\n} else {\n    return [out, out];\n}","outputs":2,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":1920,"wires":[["a74f0ea6e2c2a3ba"],["214aa6b997fd88cb"]],"outputLabels":["nominal","mark as stopped"]},{"id":"a74f0ea6e2c2a3ba","type":"function","z":"3b42aeaf229ce661","g":"53313074be779929","name":"To HomeKit","func":"var GarageDoor = msg.payload;\n\nvar output = null;\nvar obstruction = GarageDoor.Obstruction ? 1 : 0\n\nif (GarageDoor.CurrentState == \"OPENED\") {\n    output = {\n        \"payload\": {\n            \"TargetDoorState\": 0,\n            \"CurrentDoorState\": 0,\n            \"ObstructionDetected\": obstruction\n        }\n    }\n}\nelse if (GarageDoor.CurrentState == \"CLOSED\") {\n    output = {\n        \"payload\": {\n            \"TargetDoorState\": 1,\n            \"CurrentDoorState\": 1,\n            \"ObstructionDetected\": obstruction\n        }\n    }\n}\nelse if (GarageDoor.CurrentState == \"OPENING\") {\n    output = {\n        \"payload\": {\n            \"TargetDoorState\": 0,\n            \"CurrentDoorState\": 3,\n            \"ObstructionDetected\": obstruction\n        }\n    }\n}\nelse if (GarageDoor.CurrentState == \"CLOSING\") {\n    output = {\n        \"payload\": {\n            \"TargetDoorState\": 1,\n            \"CurrentDoorState\": 2,\n            \"ObstructionDetected\": obstruction\n        }\n    }\n}\nelse if (GarageDoor.CurrentState == \"STOPPED\") {\n    output = {\n        \"payload\": {\n            \"TargetDoorState\": 0,\n            \"CurrentDoorState\": 4,\n            \"ObstructionDetected\": obstruction\n        }\n    }\n}\n\nreturn output;","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":970,"y":1920,"wires":[["fcde54d08e4958a1","40c5cb84079acd30"]]},{"id":"0c941d6022c5cd0b","type":"link in","z":"3b42aeaf229ce661","g":"53313074be779929","name":"Callback","links":["84df0d7b671032d3"],"x":800,"y":1880,"wires":[["a74f0ea6e2c2a3ba"]],"l":true},{"id":"84df0d7b671032d3","type":"link out","z":"3b42aeaf229ce661","g":"53313074be779929","name":"Callback","mode":"link","links":["0c941d6022c5cd0b"],"x":1590,"y":1920,"wires":[],"l":true},{"id":"19bab88f237c34a5","type":"function","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"Push Garage Door Button","func":"return [\n    { \"payload\": { \"relay1\": 1 } },\n    { \"payload\": { \"relay1\": 0 } }\n]","outputs":2,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1370,"y":500,"wires":[["424c61e1b3530e15"],["dfc95a9d3bfa6dc2"]]},{"id":"dfc95a9d3bfa6dc2","type":"delay","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","pauseType":"delay","timeout":"300","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1570,"y":540,"wires":[["424c61e1b3530e15"]]},{"id":"424c61e1b3530e15","type":"mqtt out","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","topic":"garage/output","qos":"1","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a6979323.bc6368","x":1760,"y":500,"wires":[]},{"id":"214aa6b997fd88cb","type":"delay","z":"3b42aeaf229ce661","g":"53313074be779929","name":"","pauseType":"delay","timeout":"20","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":580,"y":1980,"wires":[["b38a9662ee994302"]]},{"id":"b38a9662ee994302","type":"function","z":"3b42aeaf229ce661","g":"53313074be779929","name":"Set as Stopped","func":"var GarageDoor = msg.payload;\nif (GarageDoor.CurrentState == \"STOPPED\") {\n    return null; // Already marked as stopped. Do nothing.\n}\n\nGarageDoor.CurrentState = \"STOPPED\";\nmsg.payload = GarageDoor;\nglobal.set(\"GarageDoor\", GarageDoor);\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":760,"y":1980,"wires":[["a74f0ea6e2c2a3ba","0c262014455895e3"]]},{"id":"fb17222e9b2660be","type":"debug","z":"3b42aeaf229ce661","g":"53313074be779929","name":"GD Homekit out 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1430,"y":1960,"wires":[]},{"id":"5e957c2c15048aa2","type":"debug","z":"3b42aeaf229ce661","g":"53313074be779929","name":"GD Homekit out 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1430,"y":2000,"wires":[]},{"id":"40c5cb84079acd30","type":"debug","z":"3b42aeaf229ce661","g":"53313074be779929","name":"GD Homekit in","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1180,"y":1900,"wires":[]},{"id":"7dbb0eea1aac665e","type":"mqtt out","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","topic":"garage/output","qos":"1","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a6979323.bc6368","x":420,"y":280,"wires":[]},{"id":"1a8f7328929e76af","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"register1\":0}","payloadType":"json","x":190,"y":140,"wires":[["7dbb0eea1aac665e"]]},{"id":"dc22bab23c29f3f8","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"register2\":1}","payloadType":"json","x":190,"y":180,"wires":[["7dbb0eea1aac665e"]]},{"id":"66619a78f32df678","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"register3\":0}","payloadType":"json","x":190,"y":220,"wires":[["7dbb0eea1aac665e"]]},{"id":"3661a1b5c607efd4","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"register4\":1}","payloadType":"json","x":190,"y":260,"wires":[["7dbb0eea1aac665e"]]},{"id":"6ff4a913e06b6945","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"register5\":2}","payloadType":"json","x":190,"y":300,"wires":[["7dbb0eea1aac665e"]]},{"id":"f0513ac32324e938","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"register6\":2}","payloadType":"json","x":190,"y":340,"wires":[["7dbb0eea1aac665e"]]},{"id":"e789bccd8abd5183","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"relay7\":1}","payloadType":"json","x":180,"y":380,"wires":[[]]},{"id":"59e7ec3be90c0020","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"register7\":0}","payloadType":"json","x":190,"y":380,"wires":[["7dbb0eea1aac665e"]]},{"id":"d006c9059497f061","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"register8\":1}","payloadType":"json","x":190,"y":420,"wires":[["7dbb0eea1aac665e"]]},{"id":"3657e9ceb9de4dce","type":"homekit-service","z":"3b42aeaf229ce661","g":"a3e903d9aed2aed7","isParent":false,"hostType":"0","bridge":"47c329efdf14f98b","accessoryId":"","parentService":"fcde54d08e4958a1","name":"Petite porte","serviceName":"ContactSensor","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.7.3","serialNo":"Default Serial Number","firmwareRev":"1.7.3","hardwareRev":"1.7.3","softwareRev":"1.7.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{\"ContactSensorState\":0}","waitForSetupMsg":false,"outputs":2,"adaptiveLightingOptionsEnable":false,"adaptiveLightingOptionsCustomTemperatureAdjustment":"","x":730,"y":860,"wires":[["6eb2a55d31759476"],[]]},{"id":"d9bb436344d11c3a","type":"function","z":"3b42aeaf229ce661","g":"a3e903d9aed2aed7","name":"Waveshare -> NodeRed contrib","func":"var payload = msg.payload;\nmsg.payload = {\n    \"ContactSensorState\": (payload ? 1 : 0)\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":840,"wires":[["3657e9ceb9de4dce","efaeb28358de1b51"]]},{"id":"6eb2a55d31759476","type":"debug","z":"3b42aeaf229ce661","g":"a3e903d9aed2aed7","name":"LD Homekit Out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":920,"y":860,"wires":[]},{"id":"ed2d8340.e1d5d8","type":"homekit-service","z":"3b42aeaf229ce661","g":"769e7ecc5f4eabec","isParent":true,"hostType":"0","bridge":"47c329efdf14f98b","accessoryId":"","parentService":"","name":"Indoor Light","serviceName":"Lightbulb","topic":"","filter":false,"manufacturer":"Nicolas Lambert","model":"Waveshare Modbus PoE Ethernet Relay (B)","serialNo":"1234567890","firmwareRev":"1","hardwareRev":"1","softwareRev":"1","cameraConfigVideoProcessor":"","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":"","cameraConfigMaxWidth":"","cameraConfigMaxHeight":"","cameraConfigMaxFPS":"","cameraConfigMaxBitrate":"","cameraConfigVideoCodec":"","cameraConfigAudioCodec":"","cameraConfigAudio":false,"cameraConfigPacketSize":"","cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"","cameraConfigMapAudio":"","cameraConfigVideoFilter":"","cameraConfigAdditionalCommandLine":"","cameraConfigDebug":false,"cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"adaptiveLightingOptionsEnable":false,"adaptiveLightingOptionsCustomTemperatureAdjustment":"","x":690,"y":1180,"wires":[["5844674e.178708","5ef517486e12d57c"],[]]},{"id":"5844674e.178708","type":"debug","z":"3b42aeaf229ce661","g":"769e7ecc5f4eabec","name":"Indoor Light HomeKit Out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":910,"y":1180,"wires":[]},{"id":"02d2c0368a0e3400","type":"function","z":"3b42aeaf229ce661","g":"769e7ecc5f4eabec","name":"Waveshare -> NodeRed contrib","func":"var payload = msg.payload;\nmsg.payload = {\n    \"On\": payload\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":450,"y":1160,"wires":[["2bf384d97786d143","ed2d8340.e1d5d8"]]},{"id":"962dd54dd2e0bc35","type":"homekit-service","z":"3b42aeaf229ce661","g":"e4ed7c71cf9a620f","isParent":false,"hostType":"0","bridge":"47c329efdf14f98b","accessoryId":"","parentService":"fcde54d08e4958a1","name":"Arrêt d'urgence","serviceName":"ContactSensor","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.7.3","serialNo":"Default Serial Number","firmwareRev":"1.7.3","hardwareRev":"1.7.3","softwareRev":"1.7.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{\"ContactSensorState\":0}","waitForSetupMsg":false,"outputs":2,"adaptiveLightingOptionsEnable":false,"adaptiveLightingOptionsCustomTemperatureAdjustment":"","x":760,"y":700,"wires":[["e67ac3b2ab26e60c"],[]]},{"id":"b19fcaf25a3a59d2","type":"function","z":"3b42aeaf229ce661","g":"e4ed7c71cf9a620f","name":"Waveshare -> NodeRed contrib","func":"var payload = msg.payload;\nmsg.payload = {\n    \"ContactSensorState\": (payload ? 1 : 0)\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":680,"wires":[["962dd54dd2e0bc35","f3d35e1cbefb017e"]]},{"id":"e67ac3b2ab26e60c","type":"debug","z":"3b42aeaf229ce661","g":"e4ed7c71cf9a620f","name":"Emmergency Button Homekit Out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1020,"y":700,"wires":[]},{"id":"32772f384b19ad28","type":"homekit-service","z":"3b42aeaf229ce661","g":"33ab9ca887a729a8","isParent":false,"hostType":"0","bridge":"47c329efdf14f98b","accessoryId":"","parentService":"fcde54d08e4958a1","name":"Activé","serviceName":"ContactSensor","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.7.3","serialNo":"Default Serial Number","firmwareRev":"1.7.3","hardwareRev":"1.7.3","softwareRev":"1.7.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{\"ContactSensorState\":0}","waitForSetupMsg":false,"outputs":2,"adaptiveLightingOptionsEnable":false,"adaptiveLightingOptionsCustomTemperatureAdjustment":"","x":650,"y":560,"wires":[["8562b9f9b47ab024"],[]]},{"id":"d41409253ef8b425","type":"mqtt in","z":"3b42aeaf229ce661","g":"33ab9ca887a729a8","name":"","topic":"garage/#","qos":"1","datatype":"auto-detect","broker":"a6979323.bc6368","nl":false,"rap":true,"rh":0,"inputs":0,"x":160,"y":540,"wires":[["9d6af6b1453acf0c"]]},{"id":"9d6af6b1453acf0c","type":"function","z":"3b42aeaf229ce661","g":"33ab9ca887a729a8","name":"Waveshare -> NodeRed contrib","func":"var payload = msg.payload;\nif (typeof payload === \"string\" && payload.trim().length === 0) {\n    return null; // Ignore empty msg\n}\n\nmsg.payload = {\n    \"ContactSensorState\": (payload.status == \"online\" ? 1 : 0)\n}\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":540,"wires":[["32772f384b19ad28","fe0e75de915f6970"]]},{"id":"8562b9f9b47ab024","type":"debug","z":"3b42aeaf229ce661","g":"33ab9ca887a729a8","name":"Device Status Homekit Out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":860,"y":560,"wires":[]},{"id":"2568f7348e3bac5a","type":"homekit-service","z":"3b42aeaf229ce661","g":"43ecc239f4b3542b","isParent":false,"hostType":"0","bridge":"47c329efdf14f98b","accessoryId":"","parentService":"fcde54d08e4958a1","name":"Barrière Infrarouge","serviceName":"ContactSensor","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.7.3","serialNo":"Default Serial Number","firmwareRev":"1.7.3","hardwareRev":"1.7.3","softwareRev":"1.7.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{\"ContactSensorState\":0}","waitForSetupMsg":false,"outputs":2,"adaptiveLightingOptionsEnable":false,"adaptiveLightingOptionsCustomTemperatureAdjustment":"","x":710,"y":1020,"wires":[["2affbc33ca2236ce"],[]]},{"id":"0c0397d5d344d4b0","type":"function","z":"3b42aeaf229ce661","g":"43ecc239f4b3542b","name":"Waveshare -> NodeRed contrib","func":"var payload = msg.payload;\nmsg.payload = {\n    \"ContactSensorState\": (payload ? 1 : 0)\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":1000,"wires":[["2568f7348e3bac5a","c2ac3c84ef273531"]]},{"id":"2affbc33ca2236ce","type":"debug","z":"3b42aeaf229ce661","g":"43ecc239f4b3542b","name":"Infrared HomeKit Out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":940,"y":1020,"wires":[]},{"id":"86879630fe7113c6","type":"link in","z":"3b42aeaf229ce661","g":"53313074be779929","name":"WS -> Garage Door","links":["24a562edd40954ab"],"x":190,"y":1920,"wires":[["aacb2ed196ebb624","1028df9240903fab"]],"l":true},{"id":"d1ea3faee897d6b8","type":"link out","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"Emmergency Button","mode":"link","links":["4ff472238317d4e1"],"x":1800,"y":140,"wires":[],"l":true},{"id":"160471fa64228dab","type":"link in","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"From Homekit","links":["4be301efb35a4e61"],"x":1150,"y":500,"wires":[["19bab88f237c34a5"]],"l":true},{"id":"4be301efb35a4e61","type":"link out","z":"3b42aeaf229ce661","g":"53313074be779929","name":"To Waveshare","mode":"link","links":["160471fa64228dab"],"x":1600,"y":1880,"wires":[],"l":true},{"id":"fd3f039dd691cab6","type":"link in","z":"3b42aeaf229ce661","g":"769e7ecc5f4eabec","name":"WS -> Indoor Light","links":["6da23ccaf8d241cb"],"x":190,"y":1160,"wires":[["02d2c0368a0e3400","29c023cb57f1cf18"]],"l":true},{"id":"6a2ca2a021420e88","type":"link in","z":"3b42aeaf229ce661","g":"43ecc239f4b3542b","name":"WS -> IR Barrier","links":["6f8768a7fd08d9f2"],"x":180,"y":1000,"wires":[["0c0397d5d344d4b0","324cf61755b8246d"]],"l":true},{"id":"f19011e79ba140eb","type":"link in","z":"3b42aeaf229ce661","g":"a3e903d9aed2aed7","name":"WS -> Little Garage Door","links":["2d4c86cf01e34d92"],"x":210,"y":840,"wires":[["d9bb436344d11c3a","ea12178801ea78c2"]],"l":true},{"id":"4ff472238317d4e1","type":"link in","z":"3b42aeaf229ce661","g":"e4ed7c71cf9a620f","name":"WS -> Emmergency Button","links":["d1ea3faee897d6b8"],"x":220,"y":680,"wires":[["b19fcaf25a3a59d2","46fd79eeac7bc75b"]],"l":true},{"id":"4f039876850134ec","type":"mqtt out","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","topic":"garage/output","qos":"1","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a6979323.bc6368","x":820,"y":280,"wires":[]},{"id":"40cb9d5703b2dc2b","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"relay1\":0}","payloadType":"json","x":600,"y":140,"wires":[["4f039876850134ec"]]},{"id":"05195e86fea7d88f","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"relay2\":0}","payloadType":"json","x":600,"y":180,"wires":[["4f039876850134ec"]]},{"id":"98fa6b739bf06a8e","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"relay3\":0}","payloadType":"json","x":600,"y":220,"wires":[["4f039876850134ec"]]},{"id":"4a4a523bdc3a372b","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"relay4\":0}","payloadType":"json","x":600,"y":260,"wires":[["4f039876850134ec"]]},{"id":"51d466375f4bc17a","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"relay5\":0}","payloadType":"json","x":600,"y":300,"wires":[["4f039876850134ec"]]},{"id":"1cb950783120399a","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"relay6\":0}","payloadType":"json","x":600,"y":340,"wires":[["4f039876850134ec"]]},{"id":"ce9adfee627055aa","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"relay7\":0}","payloadType":"json","x":600,"y":380,"wires":[["4f039876850134ec"]]},{"id":"54da1a1cc926dd8d","type":"inject","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"relay8\":0}","payloadType":"json","x":600,"y":420,"wires":[["4f039876850134ec"]]},{"id":"4201a49492e7041d","type":"comment","z":"3b42aeaf229ce661","g":"7698f88f795cda86","name":"Register codes","info":"Send {\"register1\":A} to set the first relay control mode where A indicate four control modes\n0: Normal mode, the relay is directly controlled by commands;\n1: Linkage mode, relay status is the same as the corresponding input channel status;\n2: Toggle mode, the corresponding relay toggles once when the input channel inputs a pulse;\n3: Edge Trigger Mode, the corresponding relay status changes once when the input channel level changes once","x":420,"y":240,"wires":[]},{"id":"37ef3f7079df26e8","type":"homekit-service","z":"3b42aeaf229ce661","g":"eb7b1e230cf240ab","isParent":true,"hostType":"0","bridge":"47c329efdf14f98b","accessoryId":"","parentService":"","name":"Outdoor Light","serviceName":"Lightbulb","topic":"","filter":false,"manufacturer":"Nicolas Lambert","model":"Waveshare Modbus PoE Ethernet Relay (B)","serialNo":"1234567890","firmwareRev":"1","hardwareRev":"1","softwareRev":"1","cameraConfigVideoProcessor":"","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":"","cameraConfigMaxWidth":"","cameraConfigMaxHeight":"","cameraConfigMaxFPS":"","cameraConfigMaxBitrate":"","cameraConfigVideoCodec":"","cameraConfigAudioCodec":"","cameraConfigAudio":false,"cameraConfigPacketSize":"","cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"","cameraConfigMapAudio":"","cameraConfigVideoFilter":"","cameraConfigAdditionalCommandLine":"","cameraConfigDebug":false,"cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"adaptiveLightingOptionsEnable":false,"adaptiveLightingOptionsCustomTemperatureAdjustment":"","x":740,"y":1360,"wires":[["19467429314cc3d9","1a7f00030aa8daf5"],[]]},{"id":"19467429314cc3d9","type":"debug","z":"3b42aeaf229ce661","g":"eb7b1e230cf240ab","name":"Outdoor Light HomeKit Out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1000,"y":1360,"wires":[]},{"id":"0b0aa5ea40cb700a","type":"function","z":"3b42aeaf229ce661","g":"eb7b1e230cf240ab","name":"Waveshare -> NodeRed contrib","func":"var payload = msg.payload;\nmsg.payload = {\n    \"On\": payload\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":1340,"wires":[["37ef3f7079df26e8","07c6f643cea4f359"]]},{"id":"f3a5b6652db8055e","type":"link in","z":"3b42aeaf229ce661","g":"eb7b1e230cf240ab","name":"WS -> Outdoor Light","links":["e8ccd317ba04b486"],"x":200,"y":1340,"wires":[["0b0aa5ea40cb700a","0fdf1343ba735e2c"]],"l":true},{"id":"5ef517486e12d57c","type":"function","z":"3b42aeaf229ce661","g":"769e7ecc5f4eabec","name":"Switch on/off indoor light","func":"var IndoorLight = global.get(\"IndoorLight\");\nvar currentState = IndoorLight.LightDetectionRelay;\nvar targetState = msg.payload.On;\nvar payload = null;\nif (currentState != targetState) {\n    payload = { \"relay6\": IndoorLight.IndoorLightRelay ? 0 : 1 }\n}\nmsg.payload = payload;\nreturn msg;\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":910,"y":1220,"wires":[["62f9649fb495e6a1"]]},{"id":"62f9649fb495e6a1","type":"mqtt out","z":"3b42aeaf229ce661","g":"769e7ecc5f4eabec","name":"","topic":"garage/output","qos":"1","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a6979323.bc6368","x":1140,"y":1220,"wires":[]},{"id":"1a7f00030aa8daf5","type":"function","z":"3b42aeaf229ce661","g":"eb7b1e230cf240ab","name":"Switch on/off outdoor light","func":"return { \"payload\": { \"relay5\": msg.payload.On ? 1 : 0 }};","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1000,"y":1400,"wires":[["e5985853a1703320"]]},{"id":"e5985853a1703320","type":"mqtt out","z":"3b42aeaf229ce661","g":"eb7b1e230cf240ab","name":"","topic":"garage/output","qos":"1","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a6979323.bc6368","x":1240,"y":1400,"wires":[]},{"id":"07c6f643cea4f359","type":"debug","z":"3b42aeaf229ce661","g":"eb7b1e230cf240ab","name":"Outdoor Light HomeKit In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":1320,"wires":[]},{"id":"2bf384d97786d143","type":"debug","z":"3b42aeaf229ce661","g":"769e7ecc5f4eabec","name":"Indoor Light HomeKit In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":730,"y":1140,"wires":[]},{"id":"c2ac3c84ef273531","type":"debug","z":"3b42aeaf229ce661","g":"43ecc239f4b3542b","name":"Infrared HomeKit In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":980,"wires":[]},{"id":"efaeb28358de1b51","type":"debug","z":"3b42aeaf229ce661","g":"a3e903d9aed2aed7","name":"LD Homekit In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":740,"y":820,"wires":[]},{"id":"f3d35e1cbefb017e","type":"debug","z":"3b42aeaf229ce661","g":"e4ed7c71cf9a620f","name":"Emmergency Button Homekit In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":810,"y":660,"wires":[]},{"id":"fe0e75de915f6970","type":"debug","z":"3b42aeaf229ce661","g":"33ab9ca887a729a8","name":"Device Status Homekit In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":710,"y":520,"wires":[]},{"id":"e9d9b263191322f3","type":"homekit-service","z":"3b42aeaf229ce661","g":"66bf72d212597ab4","isParent":false,"hostType":"0","bridge":"","accessoryId":"","parentService":"fcde54d08e4958a1","name":"IR Beam","serviceName":"Switch","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.7.3","serialNo":"Default Serial Number","firmwareRev":"1.7.3","hardwareRev":"1.7.3","softwareRev":"1.7.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"adaptiveLightingOptionsEnable":false,"adaptiveLightingOptionsCustomTemperatureAdjustment":"","x":680,"y":1540,"wires":[["e84612d08248611d","b03cf7694e582cdc"],[]]},{"id":"1769f9eae48a5483","type":"homekit-service","z":"3b42aeaf229ce661","g":"f22e669b997c5e7f","isParent":false,"hostType":"0","bridge":"","accessoryId":"","parentService":"fcde54d08e4958a1","name":"Lock","serviceName":"Switch","topic":"","filter":false,"manufacturer":"NRCHKB","model":"1.7.3","serialNo":"Default Serial Number","firmwareRev":"1.7.3","hardwareRev":"1.7.3","softwareRev":"1.7.3","cameraConfigVideoProcessor":"ffmpeg","cameraConfigSource":"","cameraConfigStillImageSource":"","cameraConfigMaxStreams":2,"cameraConfigMaxWidth":1280,"cameraConfigMaxHeight":720,"cameraConfigMaxFPS":10,"cameraConfigMaxBitrate":300,"cameraConfigVideoCodec":"libx264","cameraConfigAudioCodec":"libfdk_aac","cameraConfigAudio":false,"cameraConfigPacketSize":1316,"cameraConfigVerticalFlip":false,"cameraConfigHorizontalFlip":false,"cameraConfigMapVideo":"0:0","cameraConfigMapAudio":"0:1","cameraConfigVideoFilter":"scale=1280:720","cameraConfigAdditionalCommandLine":"-tune zerolatency","cameraConfigDebug":false,"cameraConfigSnapshotOutput":"disabled","cameraConfigInterfaceName":"","characteristicProperties":"{}","waitForSetupMsg":false,"outputs":2,"adaptiveLightingOptionsEnable":false,"adaptiveLightingOptionsCustomTemperatureAdjustment":"","x":730,"y":1720,"wires":[["484395482651c352","d5ee565252a16e03"],[]]},{"id":"e84612d08248611d","type":"debug","z":"3b42aeaf229ce661","g":"66bf72d212597ab4","name":"Enable Infra-Red HomeKit Out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":1540,"wires":[]},{"id":"28283fb91169bac1","type":"function","z":"3b42aeaf229ce661","g":"66bf72d212597ab4","name":"Waveshare -> NodeRed contrib","func":"var payload = msg.payload;\nmsg.payload = {\n    \"On\": !payload\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":430,"y":1520,"wires":[["7ad13ab28edb82f2","e9d9b263191322f3"]]},{"id":"b1a7e61cc43047c3","type":"link in","z":"3b42aeaf229ce661","g":"66bf72d212597ab4","name":"WS -> Enable IR","links":["76ad87f578a379ac"],"x":180,"y":1520,"wires":[["28283fb91169bac1","422f1a0d1af953ad"]],"l":true},{"id":"b03cf7694e582cdc","type":"function","z":"3b42aeaf229ce661","g":"66bf72d212597ab4","name":"Switch on/off Infra-Red","func":"return { \"payload\": { \"relay3\": msg.payload.On ? 0 : 1 }};","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":910,"y":1580,"wires":[["22b0b5d79b253db8"]]},{"id":"22b0b5d79b253db8","type":"mqtt out","z":"3b42aeaf229ce661","g":"66bf72d212597ab4","name":"","topic":"garage/output","qos":"1","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a6979323.bc6368","x":1140,"y":1580,"wires":[]},{"id":"7ad13ab28edb82f2","type":"debug","z":"3b42aeaf229ce661","g":"66bf72d212597ab4","name":"Enable Infra-Red HomeKit In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":740,"y":1500,"wires":[]},{"id":"484395482651c352","type":"debug","z":"3b42aeaf229ce661","g":"f22e669b997c5e7f","name":"Lock HomeKit Out","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":930,"y":1720,"wires":[]},{"id":"5b52a4711b519645","type":"function","z":"3b42aeaf229ce661","g":"f22e669b997c5e7f","name":"Waveshare -> NodeRed contrib","func":"var payload = msg.payload;\nmsg.payload = {\n    \"On\": payload\n}\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":1700,"wires":[["a78167ede44888f8","1769f9eae48a5483"]]},{"id":"8fa3d9fdb7735196","type":"link in","z":"3b42aeaf229ce661","g":"f22e669b997c5e7f","name":"WS -> Lock Garage Door","links":["d689a7ddd38107ba"],"x":210,"y":1700,"wires":[["5b52a4711b519645","d70866a75634525c"]],"l":true},{"id":"d5ee565252a16e03","type":"function","z":"3b42aeaf229ce661","g":"f22e669b997c5e7f","name":"Switch on/off lock garage door","func":"return { \"payload\": { \"relay7\": msg.payload.On ? 1 : 0 }};","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":970,"y":1760,"wires":[["6e906578d943deaf"]]},{"id":"6e906578d943deaf","type":"mqtt out","z":"3b42aeaf229ce661","g":"f22e669b997c5e7f","name":"","topic":"garage/output","qos":"1","retain":"false","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"a6979323.bc6368","x":1200,"y":1760,"wires":[]},{"id":"a78167ede44888f8","type":"debug","z":"3b42aeaf229ce661","g":"f22e669b997c5e7f","name":"Lock HomeKit In","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":770,"y":1680,"wires":[]},{"id":"0c262014455895e3","type":"debug","z":"3b42aeaf229ce661","g":"53313074be779929","name":"Set as stopped out","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":990,"y":1980,"wires":[]},{"id":"092a6b75ae013772","type":"rbe","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1610,"y":140,"wires":[["d1ea3faee897d6b8"]]},{"id":"24a562edd40954ab","type":"link out","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"Garage Door","mode":"link","links":["86879630fe7113c6"],"x":1770,"y":420,"wires":[],"l":true},{"id":"d689a7ddd38107ba","type":"link out","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"Lock Garage Door","mode":"link","links":["8fa3d9fdb7735196"],"x":1790,"y":380,"wires":[],"l":true},{"id":"76ad87f578a379ac","type":"link out","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"Enable IR","mode":"link","links":["b1a7e61cc43047c3"],"x":1760,"y":340,"wires":[],"l":true},{"id":"e8ccd317ba04b486","type":"link out","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"Outdoor Light","mode":"link","links":["f3a5b6652db8055e"],"x":1780,"y":300,"wires":[],"l":true},{"id":"6da23ccaf8d241cb","type":"link out","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"Indoor Light","mode":"link","links":["fd3f039dd691cab6"],"x":1770,"y":260,"wires":[],"l":true},{"id":"6f8768a7fd08d9f2","type":"link out","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"IR Barrier","mode":"link","links":["6a2ca2a021420e88"],"x":1760,"y":220,"wires":[],"l":true},{"id":"2d4c86cf01e34d92","type":"link out","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"Little Garage Door","mode":"link","links":["f19011e79ba140eb"],"x":1790,"y":180,"wires":[],"l":true},{"id":"20ebe15b435a83af","type":"rbe","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1610,"y":180,"wires":[["2d4c86cf01e34d92"]]},{"id":"5c9246a536f37021","type":"rbe","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1610,"y":220,"wires":[["6f8768a7fd08d9f2"]]},{"id":"785aeb83d47556a2","type":"rbe","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1610,"y":260,"wires":[["6da23ccaf8d241cb"]]},{"id":"2c30499c89fa632e","type":"rbe","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1610,"y":300,"wires":[["e8ccd317ba04b486"]]},{"id":"8e71cfbac3e945c8","type":"rbe","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1610,"y":340,"wires":[["76ad87f578a379ac"]]},{"id":"7adcf13825566ef4","type":"rbe","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1610,"y":380,"wires":[["d689a7ddd38107ba"]]},{"id":"b70e551b563c3de4","type":"rbe","z":"3b42aeaf229ce661","g":"fbb4904628975a0a","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":1610,"y":420,"wires":[["24a562edd40954ab"]]},{"id":"d70866a75634525c","type":"debug","z":"3b42aeaf229ce661","g":"f22e669b997c5e7f","name":"WS -> Lock Garage Door","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":1740,"wires":[]},{"id":"422f1a0d1af953ad","type":"debug","z":"3b42aeaf229ce661","g":"66bf72d212597ab4","name":"WS -> Enable IR","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":390,"y":1560,"wires":[]},{"id":"0fdf1343ba735e2c","type":"debug","z":"3b42aeaf229ce661","g":"eb7b1e230cf240ab","name":"WS -> Outdoor Light","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":440,"y":1380,"wires":[]},{"id":"29c023cb57f1cf18","type":"debug","z":"3b42aeaf229ce661","g":"769e7ecc5f4eabec","name":"WS -> Indoor Light","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":410,"y":1200,"wires":[]},{"id":"324cf61755b8246d","type":"debug","z":"3b42aeaf229ce661","g":"43ecc239f4b3542b","name":"WS -> IR Barrier","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":380,"y":1040,"wires":[]},{"id":"ea12178801ea78c2","type":"debug","z":"3b42aeaf229ce661","g":"a3e903d9aed2aed7","name":"WS -> Little Garage Door","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":470,"y":880,"wires":[]},{"id":"46fd79eeac7bc75b","type":"debug","z":"3b42aeaf229ce661","g":"e4ed7c71cf9a620f","name":"WS -> Emmergency Button","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":720,"wires":[]},{"id":"1028df9240903fab","type":"debug","z":"3b42aeaf229ce661","g":"53313074be779929","name":"WS -> Garage Door","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":420,"y":1880,"wires":[]},{"id":"a6979323.bc6368","type":"mqtt-broker","name":"Mosquitto","broker":"localhost","port":"1883","clientid":"NodeRed","autoConnect":true,"usetls":false,"protocolVersion":"5","keepalive":"60","cleansession":true,"autoUnsubscribe":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"userProps":"","sessionExpiry":""},{"id":"47c329efdf14f98b","type":"homekit-bridge","bridgeName":"Node-Red","pinCode":"023-29-425","port":"","advertiser":"ciao","allowInsecureRequest":true,"manufacturer":"NRCHKB","model":"1.5.0","serialNo":"Default Serial Number","firmwareRev":"1.5.0","hardwareRev":"1.5.0","softwareRev":"1.5.0","customMdnsConfig":false,"mdnsMulticast":true,"mdnsInterface":"","mdnsPort":"","mdnsIp":"","mdnsTtl":"","mdnsLoopback":true,"mdnsReuseAddr":true,"allowMessagePassthrough":true},{"id":"a7761eac6257a4be","type":"global-config","env":[],"modules":{"node-red-contrib-homekit-bridged":"1.7.3"}}]

Flow Info

Created 7 months, 1 week ago
Rating: not yet rated

Actions

Rate:

Node Types

Core
  • comment (x1)
  • debug (x29)
  • delay (x2)
  • function (x18)
  • inject (x17)
  • link in (x10)
  • link out (x10)
  • mqtt in (x3)
  • mqtt out (x7)
  • mqtt-broker (x1)
  • rbe (x8)
Other
  • global-config (x1)
  • group (x11)
  • homekit-bridge (x1)
  • homekit-service (x9)
  • tab (x1)

Tags

  • homekit
  • garage-door
  • mqtt
  • relay
  • modbus
  • smart-home
  • waveshare
  • automation
  • access-control
  • node-red-contrib-homekit-bridged
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option