下面的流程应该以一种模仿原生车库开门器的方式将Garageio桥接到Homekit。这是使用node-red-contrib-homekit包完成的。但是,有些事情是不对的。当TargetDoorState从Homekit节点设置为0时应该发生什么,是将请求发送到Garageio(使用模块化脚本)打开车库,然后TargetDoorState保持不变,同时从Garageio抓取CurrentDoorState五秒钟问题是,我不知道从哪里开始描述问题。我已经修复了诸如拼写错误之类的节点中的错误,并且它们只会产生更多问题。任何人都可以看看这个并指出一些可能影响这个流程功能的缺陷吗?
[
{
"id":"b958107d.b6335",
"type":"tab",
"label":"Flow 4",
"disabled":false,
"info":""
},
{
"id":"df37ea51.7e2408",
"type":"inject",
"z":"b958107d.b6335",
"name":"Every 15 Minutes",
"topic":"",
"payload":"",
"payloadType":"str",
"repeat":"900",
"crontab":"",
"once":false,
"onceDelay":0.1,
"x":210,
"y":400,
"wires":[
[
"31140bd3.427a74"
]
]
},
{
"id":"7a6ce21f.d570bc",
"type":"inject",
"z":"b958107d.b6335",
"name":"Every 5 Seconds",
"topic":"",
"payload":"",
"payloadType":"str",
"repeat":"5",
"crontab":"",
"once":false,
"onceDelay":0.1,
"x":210,
"y":660,
"wires":[
[
"dcd5850b.fef318"
]
]
},
{
"id":"31140bd3.427a74",
"type":"exec",
"z":"b958107d.b6335",
"command":"/home/carter/garage/scripts/renew",
"addpay":false,
"append":"",
"useSpawn":"false",
"timer":"",
"oldrc":false,
"name":"Renew Authentication",
"x":460,
"y":400,
"wires":[
[
],
[
],
[
]
]
},
{
"id":"dcd5850b.fef318",
"type":"exec",
"z":"b958107d.b6335",
"command":"/home/carter/garage/scripts/status",
"addpay":false,
"append":"",
"useSpawn":"false",
"timer":"",
"oldrc":false,
"name":"Get Status",
"x":430,
"y":660,
"wires":[
[
"eb7aa22f.20c8d",
"498df0d3.d4573"
],
[
],
[
]
]
},
{
"id":"9955aba3.f58108",
"type":"exec",
"z":"b958107d.b6335",
"command":"/home/carter/garage/scripts/close",
"addpay":true,
"append":"",
"useSpawn":"false",
"timer":"",
"oldrc":false,
"name":"POST Close",
"x":2090,
"y":600,
"wires":[
[
"9d1ae463.3415e8"
],
[
],
[
]
]
},
{
"id":"994542c8.d4801",
"type":"exec",
"z":"b958107d.b6335",
"command":"/home/carter/garage/scripts/open",
"addpay":false,
"append":"",
"useSpawn":"false",
"timer":"",
"oldrc":false,
"name":"POST Open",
"x":2090,
"y":720,
"wires":[
[
"abfaea0c.cf3608"
],
[
],
[
]
]
},
{
"id":"f03f1531.aa66e8",
"type":"file",
"z":"b958107d.b6335",
"name":"Write to File",
"filename":"/home/carter/garage/vars/tds",
"appendNewline":false,
"createDir":false,
"overwriteFile":"true",
"x":2550,
"y":720,
"wires":[
]
},
{
"id":"2778e858.697218",
"type":"file",
"z":"b958107d.b6335",
"name":"Write to File",
"filename":"/home/carter/garage/vars/tds",
"appendNewline":false,
"createDir":false,
"overwriteFile":"true",
"x":2550,
"y":600,
"wires":[
]
},
{
"id":"253a0e02.550b52",
"type":"switch",
"z":"b958107d.b6335",
"name":"",
"property":"payload.TargetDoorState",
"propertyType":"msg",
"rules":[
{
"t":"eq",
"v":"1",
"vt":"num"
},
{
"t":"eq",
"v":"0",
"vt":"num"
}
],
"checkall":"true",
"repair":false,
"outputs":2,
"x":1850,
"y":660,
"wires":[
[
"9955aba3.f58108"
],
[
"994542c8.d4801"
]
]
},
{
"id":"9d1ae463.3415e8",
"type":"change",
"z":"b958107d.b6335",
"name":"",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"1",
"tot":"num"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":2320,
"y":600,
"wires":[
[
"2778e858.697218",
"c83a643c.349788",
"1c403c26.e50284"
]
]
},
{
"id":"abfaea0c.cf3608",
"type":"change",
"z":"b958107d.b6335",
"name":"",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"0",
"tot":"num"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":2320,
"y":720,
"wires":[
[
"f03f1531.aa66e8",
"b056b7c4.7ac138",
"3bca3efe.237552"
]
]
},
{
"id":"3bca3efe.237552",
"type":"file",
"z":"b958107d.b6335",
"name":"Flag as Changing State",
"filename":"/home/carter/garage/vars/changing",
"appendNewline":false,
"createDir":false,
"overwriteFile":"true",
"x":2590,
"y":680,
"wires":[
]
},
{
"id":"498df0d3.d4573",
"type":"file in",
"z":"b958107d.b6335",
"name":"Check Flag",
"filename":"/home/carter/garage/vars/changing",
"format":"utf8",
"chunk":false,
"sendError":false,
"x":650,
"y":660,
"wires":[
[
"919f30b2.fd435"
]
]
},
{
"id":"eb7aa22f.20c8d",
"type":"switch",
"z":"b958107d.b6335",
"name":"What's the state?",
"property":"payload",
"propertyType":"msg",
"rules":[
{
"t":"cont",
"v":"closed",
"vt":"str"
},
{
"t":"cont",
"v":"open",
"vt":"str"
}
],
"checkall":"true",
"repair":false,
"outputs":2,
"x":670,
"y":980,
"wires":[
[
"3097905d.4b7f5"
],
[
"170d3830.0c2528"
]
]
},
{
"id":"3097905d.4b7f5",
"type":"change",
"z":"b958107d.b6335",
"name":"Closed",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"1",
"tot":"num"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":920,
"y":920,
"wires":[
[
"c8f8bf80.72181",
"f7605409.237dc8"
]
]
},
{
"id":"170d3830.0c2528",
"type":"change",
"z":"b958107d.b6335",
"name":"Open",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"0",
"tot":"num"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":910,
"y":1040,
"wires":[
[
"fcf1b6e7.a94ff8",
"238c6754.5f47d8"
]
]
},
{
"id":"c8f8bf80.72181",
"type":"file",
"z":"b958107d.b6335",
"name":"Write to File",
"filename":"/home/carter/garage/vars/cds",
"appendNewline":false,
"createDir":false,
"overwriteFile":"true",
"x":1150,
"y":920,
"wires":[
]
},
{
"id":"fcf1b6e7.a94ff8",
"type":"file",
"z":"b958107d.b6335",
"name":"Write to File",
"filename":"/home/carter/garage/vars/cds",
"appendNewline":false,
"createDir":false,
"overwriteFile":"true",
"x":1130,
"y":1040,
"wires":[
]
},
{
"id":"919f30b2.fd435",
"type":"switch",
"z":"b958107d.b6335",
"name":"Is Flag Set?",
"property":"payload",
"propertyType":"msg",
"rules":[
{
"t":"eq",
"v":"1",
"vt":"num"
},
{
"t":"else"
}
],
"checkall":"true",
"repair":false,
"outputs":2,
"x":790,
"y":560,
"wires":[
[
"b97366ab.e6f5c8"
],
[
"d94542f3.a9a38"
]
]
},
{
"id":"d94542f3.a9a38",
"type":"file in",
"z":"b958107d.b6335",
"name":"No (Get Current State)",
"filename":"/home/carter/garage/vars/cds",
"format":"utf8",
"chunk":false,
"sendError":false,
"x":1040,
"y":660,
"wires":[
[
"b51b8ac4.bf56a8"
]
]
},
{
"id":"b51b8ac4.bf56a8",
"type":"switch",
"z":"b958107d.b6335",
"name":"Whats the state?",
"property":"payload",
"propertyType":"msg",
"rules":[
{
"t":"eq",
"v":"1",
"vt":"num"
},
{
"t":"eq",
"v":"0",
"vt":"num"
}
],
"checkall":"true",
"repair":false,
"outputs":2,
"x":1270,
"y":660,
"wires":[
[
"616445ea.a0d8dc"
],
[
"925a9ecb.31de7"
]
]
},
{
"id":"616445ea.a0d8dc",
"type":"change",
"z":"b958107d.b6335",
"name":"Closed",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"{\"CurrentDoorState\":1,\"TargetDoorState\":1}",
"tot":"json"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":1460,
"y":600,
"wires":[
[
"5aaf7b8d.70aa14"
]
]
},
{
"id":"925a9ecb.31de7",
"type":"change",
"z":"b958107d.b6335",
"name":"Open",
"rules":[
{
"t":"set",
"p":"payload",
"pt":"msg",
"to":"{\"CurrentDoorState\":0,\"TargetDoorState\":0}",
"tot":"json"
}
],
"action":"",
"property":"",
"from":"",
"to":"",
"reg":false,
"x":1450,
"y":720,
"wires":[
[
"5aaf7b8d.70aa14"
]
]
},
{
"id":"b97366ab.e6f5c8",
"type":"function",
"z":"b958107d.b6335",
"name":"Flag Triggered (Compare the values.)",
"func":"var CDS = global.get(\"CDS\");\nvar TDS = global.get(\"TDS\");\n\nif (CDS == TDS) {\n msg.payload = \"same\";\n } else {\n msg.payload = \"different\";\n}",
"outputs":1,
"noerr":0,
"x":970,
"y":460,
"wires":[
[
"47743f0.13daac",
"81d95da8.e8a44"
]
]
},
{
"id":"f7605409.237dc8",
"type":"function",
"z":"b958107d.b6335",
"name":"Set Global Variable",
"func":"global.set(\"CDS\", 1)",
"outputs":1,
"noerr":0,
"x":1170,
"y":860,
"wires":[
[
]
]
},
{
"id":"238c6754.5f47d8",
"type":"function",
"z":"b958107d.b6335",
"name":"Set Global Variable",
"func":"global.set(\"CDS\", 0)",
"outputs":1,
"noerr":0,
"x":1150,
"y":1100,
"wires":[
[
]
]
},
{
"id":"b056b7c4.7ac138",
"type":"function",
"z":"b958107d.b6335",
"name":"Set Global Variable",
"func":"global.set(\"TDS\", 0)",
"outputs":1,
"noerr":0,
"x":2570,
"y":760,
"wires":[
[
]
]
},
{
"id":"c83a643c.349788",
"type":"function",
"z":"b958107d.b6335",
"name":"Set Global Variable",
"func":"global.set(\"TDS\", 1)",
"outputs":1,
"noerr":0,
"x":2570,
"y":560,
"wires":[
[
]
]
},
{
"id":"47743f0.13daac",
"type":"switch",
"z":"b958107d.b6335",
"name":"Are they the same?",
"property":"payload",
"propertyType":"msg",
"rules":[
{
"t":"eq",
"v":"same",
"vt":"str"
},
{
"t":"eq",
"v":"different",
"vt":"str"
}
],
"checkall":"true",
"repair":false,
"outputs":2,
"x":1230,
"y":460,
"wires":[
[
"81d95da8.e8a44",
"9d51ba2e.5e2068"
],
[
"a485cea6.9391e"
]
]
},
{
"id":"898514ea.ccbd98",
"type":"file",
"z":"b958107d.b6335",
"name":"Reset Flag",
"filename":"/home/carter/garage/vars/changing",
"appendNewline":false,
"createDir":false,
"overwriteFile":"delete",
"x":1640,
"y":360,
"wires":[
]
},
{
"id":"81d95da8.e8a44",
"type":"debug",
"z":"b958107d.b6335",
"name":"",
"active":true,
"tosidebar":true,
"console":false,
"tostatus":false,
"complete":"false",
"x":1230,
"y":320,
"wires":[
]
},
{
"id":"1c403c26.e50284",
"type":"file",
"z":"b958107d.b6335",
"name":"Flag as Changing State",
"filename":"/home/carter/garage/vars/changing",
"appendNewline":false,
"createDir":false,
"overwriteFile":"true",
"x":2590,
"y":640,
"wires":[
]
},
{
"id":"9d51ba2e.5e2068",
"type":"function",
"z":"b958107d.b6335",
"name":"Same",
"func":"msg.payload.TargetDoorState = global.get(\"CDS\")\nmsg.payload.CurrentDoorState = global.get(\"CDS\")\nreturn msg;\n",
"outputs":1,
"noerr":0,
"x":1410,
"y":400,
"wires":[
[
"898514ea.ccbd98",
"5aaf7b8d.70aa14"
]
]
},
{
"id":"a485cea6.9391e",
"type":"function",
"z":"b958107d.b6335",
"name":"Different",
"func":"msg.payload.CurrentDoorState = global.get(\"CDS\")\nmsg.payload.TargetDoorState = global.get(\"TDS\")\nreturn msg;",
"outputs":1,
"noerr":0,
"x":1420,
"y":480,
"wires":[
[
"5aaf7b8d.70aa14"
]
]
},
{
"id":"e80c8bfd.7c1e38",
"type":"inject",
"z":"b958107d.b6335",
"name":"Close",
"topic":"",
"payload":"{\"CurrentDoorState\":1,\"TargetDoorState\":1}",
"payloadType":"json",
"repeat":"",
"crontab":"",
"once":false,
"onceDelay":0.1,
"x":1510,
"y":920,
"wires":[
[
"5aaf7b8d.70aa14"
]
]
},
{
"id":"99f97edb.06267",
"type":"inject",
"z":"b958107d.b6335",
"name":"Open",
"topic":"",
"payload":"{\"CurrentDoorState\":0,\"TargetDoorState\":0}",
"payloadType":"json",
"repeat":"",
"crontab":"",
"once":false,
"onceDelay":0.1,
"x":1510,
"y":960,
"wires":[
[
"5aaf7b8d.70aa14"
]
]
},
{
"id":"5aaf7b8d.70aa14",
"type":"homekit-service",
"z":"b958107d.b6335",
"accessory":"84bf4323.627db",
"name":"Main Garage",
"serviceName":"GarageDoorOpener",
"x":1650,
"y":660,
"wires":[
[
"253a0e02.550b52"
]
]
},
{
"id":"c3a8e2c.70bb52",
"type":"comment",
"z":"b958107d.b6335",
"name":"Get the status every 5 seconds.",
"info":"",
"x":290,
"y":720,
"wires":[
]
},
{
"id":"9f4f1241.e9102",
"type":"comment",
"z":"b958107d.b6335",
"name":"Retrieve the flag file and check if its active.",
"info":"",
"x":740,
"y":700,
"wires":[
]
},
{
"id":"f2482231.68842",
"type":"comment",
"z":"b958107d.b6335",
"name":"Write the CDS to a file.",
"info":"",
"x":840,
"y":1160,
"wires":[
]
},
{
"id":"e37ab710.a21a88",
"type":"comment",
"z":"b958107d.b6335",
"name":"Get the CDS, set it to the TDS, and then feed to HomeKit.",
"info":"",
"x":1290,
"y":780,
"wires":[
]
},
{
"id":"80991a7f.6a9318",
"type":"comment",
"z":"b958107d.b6335",
"name":"Compare the global variables. If they are different, the garage is moving, and if they are the same it has stopped.",
"info":"",
"x":1180,
"y":260,
"wires":[
]
},
{
"id":"6f9b114b.d6bfc",
"type":"comment",
"z":"b958107d.b6335",
"name":"Delete the flag file, causing the check flag node to throw an error and choose the bottom route.",
"info":"",
"x":1860,
"y":320,
"wires":[
]
},
{
"id":"e64d88ba.07c8d8",
"type":"comment",
"z":"b958107d.b6335",
"name":"Send the CDS as the CDS and TDS to HomeKit.",
"info":"",
"x":1660,
"y":400,
"wires":[
]
},
{
"id":"23731949.23c5f6",
"type":"comment",
"z":"b958107d.b6335",
"name":"Keep the TDS the same, but report the CDS to HomeKit.",
"info":"",
"x":1710,
"y":480,
"wires":[
]
},
{
"id":"efbfb7a4.54f3b8",
"type":"comment",
"z":"b958107d.b6335",
"name":"TDS = TargetDoorState",
"info":"",
"x":220,
"y":240,
"wires":[
]
},
{
"id":"9fb611a6.678ef",
"type":"comment",
"z":"b958107d.b6335",
"name":"CDS = CurrentDoorState",
"info":"",
"x":230,
"y":280,
"wires":[
]
},
{
"id":"2562abf.ab67554",
"type":"comment",
"z":"b958107d.b6335",
"name":" 0 = Open",
"info":"",
"x":180,
"y":320,
"wires":[
]
},
{
"id":"a7327588.c00208",
"type":"comment",
"z":"b958107d.b6335",
"name":"1 = Closed",
"info":"",
"x":180,
"y":360,
"wires":[
]
},
{
"id":"84bf4323.627db",
"type":"homekit-accessory",
"z":"",
"accessoryName":"Main",
"pinCode":"111-11-111",
"port":"",
"manufacturer":"Default Manufacturer",
"model":"Default Model",
"serialNo":"Default Serial Number",
"accessoryType":"4"
}
]