Chirila Radu
Published © GPL3+

Interfacing Apple HomeKit with the Node-RED Smart Home

This project aims to show you how to integrate the Apple HomeKit with a Raspberry Pi Smart Home infrastructure coded using Node-RED.

BeginnerProtip1 hour3,986
Interfacing Apple HomeKit with the Node-RED Smart Home

Things used in this project

Hardware components

Raspberry Pi Zero Wireless
Raspberry Pi Zero Wireless
×1

Software apps and online services

Node-RED
Node-RED

Story

Read more

Code

Node-RED schematic (Import)

JSON
[{"id":"57969186.fa49f","type":"inject","z":"e9c52d1e.5afdf","name":"","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":100,"wires":[["d86dbaf0.372fc"]]},{"id":"d86dbaf0.372fc","type":"exec","z":"e9c52d1e.5afdf","command":"vcgencmd measure_temp","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":true,"name":"Measure CPU Temp","x":300,"y":120,"wires":[["c2260922.862868"],[],[]]},{"id":"c2260922.862868","type":"function","z":"e9c52d1e.5afdf","name":"cpu temp processor","func":"str=msg.payload;\nmsg.payload={\n    CurrentTemperature: parseFloat(str.substring(5,11))\n}\nreturn msg;","outputs":1,"noerr":0,"x":540,"y":120,"wires":[["5c53103c.84f3f"]]},{"id":"5c53103c.84f3f","type":"homekit-service","z":"e9c52d1e.5afdf","accessory":"70d2eaf2.3d79c4","name":"CPU TEMP","serviceName":"TemperatureSensor","x":730,"y":120,"wires":[["712963a2.6953f4"]]},{"id":"712963a2.6953f4","type":"debug","z":"e9c52d1e.5afdf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":790,"y":180,"wires":[]},{"id":"d6cbe6db.bcc89","type":"inject","z":"e9c52d1e.5afdf","name":"","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":280,"wires":[["d1929e42.2036"]]},{"id":"5be68429.d96ed4","type":"homekit-service","z":"e9c52d1e.5afdf","accessory":"226ad4a0.1b8694","name":"CPU Load","serviceName":"HumiditySensor","x":690,"y":280,"wires":[["3dc8bf87.5f02b"]]},{"id":"3dc8bf87.5f02b","type":"debug","z":"e9c52d1e.5afdf","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":830,"y":340,"wires":[]},{"id":"d1929e42.2036","type":"exec","z":"e9c52d1e.5afdf","command":"top -d 0.5 -b -n2 | grep \"Cpu(s)\"|tail -n 1 | awk '{print $2 + $4}'","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Cpu Load","x":300,"y":280,"wires":[["25bb8efe.b7317a"],[],[]]},{"id":"25bb8efe.b7317a","type":"function","z":"e9c52d1e.5afdf","name":"cpu load processor","func":"msg.payload={\n    CurrentRelativeHumidity: parseInt(msg.payload)\n}\nreturn msg;","outputs":1,"noerr":0,"x":510,"y":280,"wires":[["5be68429.d96ed4"]]},{"id":"9d04e888.f151b8","type":"homekit-service","z":"e9c52d1e.5afdf","accessory":"980890ed.2f5a1","name":"Relay One","serviceName":"Switch","x":110,"y":400,"wires":[["f3c80729.9b281"]]},{"id":"f3c80729.9b281","type":"function","z":"e9c52d1e.5afdf","name":"relay","func":"if (msg.payload.On===true)\n    msg.payload=1;\nelse \n    msg.payload=0;\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":400,"wires":[["bf2dd3f0.f64d6"]]},{"id":"bf2dd3f0.f64d6","type":"rpi-gpio out","z":"e9c52d1e.5afdf","name":"RELAY1","pin":"12","set":"","level":"0","freq":"","out":"out","x":440,"y":400,"wires":[]},{"id":"7891ea2d.c686bc","type":"function","z":"e9c52d1e.5afdf","name":"relay","func":"if (msg.payload.On===true)\n    msg.payload=1;\nelse \n    msg.payload=0;\nreturn msg;","outputs":1,"noerr":0,"x":290,"y":460,"wires":[["b850af20.ed46c"]]},{"id":"b850af20.ed46c","type":"rpi-gpio out","z":"e9c52d1e.5afdf","name":"RELAY2","pin":"11","set":"","level":"0","freq":"","out":"out","x":440,"y":460,"wires":[]},{"id":"34ddc0df.f14ef","type":"homekit-service","z":"e9c52d1e.5afdf","accessory":"1e62fea.3a64681","name":"Relay Two","serviceName":"Switch","x":110,"y":460,"wires":[["7891ea2d.c686bc"]]},{"id":"450954e4.ea0944","type":"homekit-service","z":"e9c52d1e.5afdf","accessory":"7fd8926b.b560ac","name":"Info","serviceName":"ProtocolInformation","x":550,"y":520,"wires":[[]]},{"id":"afa4861c.b16748","type":"function","z":"e9c52d1e.5afdf","name":"cpu temp processor","func":"str=msg.payload;\nmsg.payload={\n    homekit:HeatingCoolingMode: \"FooBar test string\"\n}\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":520,"wires":[["450954e4.ea0944"]]},{"id":"c087955d.bf505","type":"inject","z":"e9c52d1e.5afdf","name":"","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":110,"y":520,"wires":[["afa4861c.b16748"]]},{"id":"70d2eaf2.3d79c4","type":"homekit-accessory","z":"","accessoryName":"CPU Temperature","pinCode":"321-32-321","port":"","manufacturer":"Default Manufacturer","model":"Radu Mk-01","serialNo":"Default Serial Number","accessoryType":"10"},{"id":"226ad4a0.1b8694","type":"homekit-accessory","z":"","accessoryName":"CPU Load","pinCode":"111-11-111","port":"","manufacturer":"Default Manufacturer","model":"Radu Mk-01","serialNo":"Default Serial Number","accessoryType":"10"},{"id":"980890ed.2f5a1","type":"homekit-accessory","z":"","accessoryName":"Relay One","pinCode":"223-22-223","port":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","accessoryType":"8"},{"id":"1e62fea.3a64681","type":"homekit-accessory","z":"","accessoryName":"Relay two","pinCode":"111-11-115","port":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","accessoryType":"8"},{"id":"7fd8926b.b560ac","type":"homekit-accessory","z":"","accessoryName":"Info","pinCode":"111-11-112","port":"","manufacturer":"Default Manufacturer","model":"Default Model","serialNo":"Default Serial Number","accessoryType":"9"}]

Credits

Chirila Radu

Chirila Radu

2 projects • 0 followers

Comments