Hi,
since a long time I want to add homekit to my home automation, but the node I have written is so buggy that half the time it doesn't work. If you look at the debug it's also obvious why.
So, I use the node-red-contrib-homekit-bridged to unlock my door.
Whats's the logic action I need?
- I push on the lock Icon on my Iphone
- My homekit node zijdeur sends out LockTargetState : 0
- This needs to be acknowledged by LockCurrentState : 0
At this time my door is open, because the pulse is enough for my door This Pulse is transfered by modbus but that's not important here.
After 4 seconds my door automatically lock's back again, so this I also wan't to see on my Iphone. Therefore... - After 4 seconds I generate a LockTargetState: 1
- Again, this needs to be confirmed by a LockCurrentState: 1
So actually, 4 program steps are needed.
Also, if possible, on initialization the door needs to be locked, so LockCurrentState: 1 at startup.
But I'm not happy with what I have made. I just can't get away with this 'node' language. I'm very familiar in Structured Text.
It's the 'circled' piece that needs tobe improved, is as less blocks as possible.
This is my program
[{"id":"3a68d0f5.9e89b","type":"change","z":"93b1b9fe.021678","name":"Acknowledge Target State","rules":[{"t":"move","p":"payload.LockTargetState","pt":"msg","to":"payload.LockCurrentState","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":207.01752281188965,"y":289.3334641456604,"wires":[["cc94e4b9.a72198"]]},{"id":"cc94e4b9.a72198","type":"delay","z":"93b1b9fe.021678","name":"","pauseType":"delay","timeout":"500","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":410.85077476501465,"y":289.00000524520874,"wires":[["e2858010.1649f","91dc72cd.cbc03","d8346625.ed7288"]]},{"id":"e2858010.1649f","type":"change","z":"93b1b9fe.021678","name":"Set Lock State","rules":[{"t":"set","p":"payload.LockTargetState","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":622.017370223999,"y":356.33338594436646,"wires":[["f3637270.24692"]]},{"id":"f3637270.24692","type":"delay","z":"93b1b9fe.021678","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":794.8507061004639,"y":356.00001192092896,"wires":[["91dc72cd.cbc03","42fbfcf0.0ff784"]]},{"id":"b8278997.c80a48","type":"function","z":"93b1b9fe.021678","name":"Deur openen","func":"var x = msg.payload.LockTargetState;\nif (x== \"0\") {\n var msg_o = {payload : 1}\n} \nreturn msg_o;\n\n","outputs":1,"noerr":0,"x":752.8508262634277,"y":164.99999809265137,"wires":[["9e11f920.4ff558"]]},{"id":"91dc72cd.cbc03","type":"homekit-service","z":"93b1b9fe.021678","bridge":"41183ea0.85f1a","name":"Zijdeur","serviceName":"LockMechanism","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","characteristicProperties":"{}","x":348.0694236755371,"y":170.04864501953125,"wires":[["3a68d0f5.9e89b","b8278997.c80a48","c275987b.93deb8"]]},{"id":"d8346625.ed7288","type":"debug","z":"93b1b9fe.021678","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":582.4167041778564,"y":515.5035419464111,"wires":[]},{"id":"10b19e45.79daa2","type":"inject","z":"93b1b9fe.021678","name":"","topic":"","payload":"{\"LockTargetState\":\"1\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":157.40625762939453,"y":41.97223091125488,"wires":[["91dc72cd.cbc03"]]},{"id":"c275987b.93deb8","type":"debug","z":"93b1b9fe.021678","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":483.4131832122803,"y":77.4930648803711,"wires":[]},{"id":"118e6da0.881352","type":"inject","z":"93b1b9fe.021678","name":"","topic":"","payload":"{\"LockTargetState\":\"0\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":155.35069274902344,"y":89.01041412353516,"wires":[["91dc72cd.cbc03"]]},{"id":"42fbfcf0.0ff784","type":"debug","z":"93b1b9fe.021678","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1034.4028072357178,"y":408.50000762939453,"wires":[]},{"id":"41183ea0.85f1a","type":"homekit-bridge","z":"","bridgeName":"NodeRed","pinCode":"111-11-111","port":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number"}]
Thank you to who has time for this.
Br
Nick