Hello everyone! I wanted to share my experience with creating intelligent scenes using HomeKit, openHAB, and node-RED. As someone with a variable work schedule and young children, automating our routines has been a bit of a challenge. However, scenes have proven to be a convenient way to send batch commands to multiple devices, making life much easier.
I’ve been a fan of Apple products, so HomeKit scenes seemed like a natural fit. They’re accessible via Siri and the Home app on my watch, phone, and computer. The HomeRun app on my Apple Watch has been especially handy as a remote control for my home. However, I ran into some issues with HomeKit items resetting themselves, which broke my automations and required frequent setup. Additionally, openHAB wasn’t fully integrated into the scene setup, making it difficult to incorporate HABpanel into my control scheme.
To solve these problems, I came up with a solution using node-RED, openHAB, and HomeKit. Here’s how it works:
-
node-RED Contains the Scene Logic: Node-RED acts as the brain behind the scenes, handling the logic and communication between devices.
-
openHAB Has Scene Dimmer Items: Each zone or area that needs control has a scene dimmer item in openHAB.
-
HomeKit Has Dimmer Items: These correspond to the items in openHAB, allowing seamless integration.
The result is very intuitive and seamless. Whether I use Siri on my watch, press a button on HABpanel, or make a selection in the openHAB phone app, the lights adjust to the preset levels. This setup has been a game-changer for our family!
To implement this, you’ll need a working node-RED installation connected to openHAB and HomeKit. I also recommend using the Gate node for smoother operations. If you’re interested in learning more, I’ve included some recommended reading below.
Here’s a snapshot of my node-RED flow for demonstration purposes:
[
{
“id”: “68d4a16b.219e28”,
“type”: “tab”,
“label”: “Demo”,
“disabled”: false,
“info”: “”
},
{
“id”: “7644c54e.e076fc”,
“type”: “openhab2-in”,
“z”: “68d4a16b.219e28”,
“name”: “”,
“controller”: “e80889f5.d5d3c”,
“itemname”: “S_SYSP_SceneL3”,
“x”: 150,
“y”: 100,
“wires”: [
[
“b194e02c.8fa5”
],
]
},
{
“id”: “b194e02c.8fa5”,
“type”: “delay”,
“z”: “68d4a16b.219e28”,
“name”: “”,
“pauseType”: “rate”,
“timeout”: “5”,
“timeoutUnits”: “seconds”,
“rate”: “1”,
“nbRateUnits”: “5”,
“rateUnits”: “second”,
“randomFirst”: “1”,
“randomLast”: “5”,
“randomUnits”: “seconds”,
“drop”: false,
“x”: 340,
“y”: 100,
“wires”: [
[
“f34fcb43.75bb7”
]
]
},
{
“id”: “f34fcb43.75bb7”,
“type”: “gate”,
“z”: “68d4a16b.219e28”,
“name”: “”,
“controlTopic”: “control”,
“defaultState”: “closed”,
“openCmd”: “open”,
“closeCmd”: “close”,
“toggleCmd”: “toggle”,
“defaultCmd”: “default”,
“persist”: false,
“x”: 510,
“y”: 100,
“wires”: [
[
“161d5763.1a8ae9”,
“26f5490c.7954f6”
]
]
},
{
“id”: “161d5763.1a8ae9”,
“type”: “function”,
“z”: “68d4a16b.219e28”,
“name”: “OH to HK”,
“func”: “var input = msg.payload;\nif (input < 101){\n if (input < 1) {\n msg.payload = {\n "On": false\n }\n }\n else {\n msg.payload = {\n "Brightness": input,\n //"On": true\n }\n }\n return msg;\n}”,
“outputs”: 1,
“noerr”: 0,
“x”: 660,
“y”: 100,
“wires”: [
[
“eeb09538.2b936”
]
]
},
{
“id”: “26f5490c.7954f6”,
“type”: “switch”,
“z”: “68d4a16b.219e28”,
“name”: “”,
“property”: “payload”,
“propertyType”: “msg”,
“rules”: [
{
“t”: “eq”,
“v”: “0”,
“vt”: “str”
},
{
“t”: “eq”,
“v”: “30”,
“vt”: “str”
},
{
“t”: “eq”,
“v”: “33”,
“vt”: “str”
},
{
“t”: “eq”,
“v”: “48”,
“vt”: “str”
},
{
“t”: “eq”,
“v”: “57”,
“vt”: “str”
}
],
“checkall”: “true”,
“repair”: false,
“outputs”: 5,
“x”: 670,
“y”: 260,
“wires”: [
[
“ffb96108.6fec8”
],
[
“fdc331b3.999af8”
],
[
“5a6c1592.6647a4”
],
[
“13c33928.694c47”
],
[
“887082f3.3ba72”
]
]
},
{
“id”: “eeb09538.2b936”,
“type”: “homekit-service”,
“z”: “68d4a16b.219e28”,
“isParent”: true,
“bridge”: “d9992c49.b8d12”,
“parentService”: “”,
“name”: “SceneL3”,
“serviceName”: “Lightbulb”,
“topic”: “”,
“filter”: false,
“manufacturer”: “Scene Interop”,
“model”: “V1”,
“serialNo”: “Virtual”,
“cameraConfigVideoProcessor”: “”,
“cameraConfigSource”: “”,
“cameraConfigStillImageSource”: “”,
“cameraConfigMaxStreams”: “”,
“cameraConfigMaxWidth”: “”,
“cameraConfigMaxHeight”: “”,
“cameraConfigMaxFPS”: “”,
“cameraConfigMaxBitrate”: “”,
“cameraConfigVideoCodec”: “”,
“cameraConfigAudioCodec”: “”,
“cameraConfigAudio”: false,
“cameraConfigPacketSize”: “”,
“cameraConfigVerticalFlip”: false,
“cameraConfigHorizontalFlip”: false,
“cameraConfigMapVideo”: “”,
“cameraConfigMapAudio”: “”,
“cameraConfigVideoFilter”: “”,
“cameraConfigAdditionalCommandLine”: “”,
“cameraConfigDebug”: false,
“characteristicProperties”: “"{"Brightness":true}"”,
“x”: 800,
“y”: 100,
“wires”: [
[
“dc46953d.cb38f”
],
],
“inputLabels”: [
“"{"Brightness":true}"”
]
}
]
This setup has been a great solution for our family, and I hope it can help others looking to integrate these systems. If you have any questions or need assistance, feel free to reach out! Happy automating! ![]()