deCONZ and Node-RED

Reading Time: 3 minutes
deCONZ in Node-RED

This was a bit of a nightmare for something that should have been really simple. I was being thick and I missed something critical in the instructions. I thought I’d document it here just in case others find it useful, or I ever have to do it again because I WILL forget!

If you have a Conbee II USB stick working through the deCONZ/Phoscon integration in Home Assistant and want certain things to be exposed to Node-RED then you’ll need to do this. Just as a recap, take a sensor. The sensor will get picked up by HA as a device once it’s been added to deCONZ/Phoscon. Temperature, motion, light, etc, will all be entities. in my case, I have an IKEA Tradfri Dimmer that I wanted to use with Node-RED but the switch part doesn’t show as an entity, only the battery level does. Node-RED, by default, works with entities.

The way to get this working is to add node-red-contrib-deconz to Node-RED. This gives you a bunch of deCONZ/Phoscon specific nodes to use for automations, like the first node in the image above.

So, get yourself over to the Node-RED library and get the code to import

Then go into the deCONZ configuration tab by clicking on the deCONZ add-on in Supervisor of Home Assistant.

Network configuration of deCONZ add-on

This is the bit that I missed. It is there in the instructions. All three of those bits under “Host” will be marked as disabled. Just enter 40850 in the top one and 8081 in the bottom one. When you save, make you you restart.

Now, I think the best thing to do here is to have your Phoscon open in one tab and Node-RED in another. Under “Advanced” in the settings screen for your gateway in Phoscon you’ll see the section below.

Advanced settings for Phoscon gateway

What you need to do, once you’re ready, is click that “Authenticate app” button. You’ll then have 60 seconds to get into Node-RED and do what you need in there.

In Node-RED, now you have the imported contribution, the easiest thing is just to drag a deCONZ “in” node onto the screen and double click on it. You’ll be invited to add a new deconz server. You should then see a screen like the one below.

deCONZ server config screen

The name is whatever you want. The IP Address is the same one you use to connect to your Home Assistant back end. Fill in the port and WebSocket Port as above. Leave the API Key blank.

Click “Get Settings” and it should populate the API Key.

Click “Done”.

Now, when you look at the deCONZ node you dragged in you should see something like this where all your devices are listed.

deCONZ devices

If you don’t see any devices, you might just have to restart Node-RED.

Once that’s done, you’ll have access to data from all your deCONZ devices to use in your Node-RED flows. The best thing to do is try one and add a debug node after the deCONZ node. Do something so that the device changes state and you’ll see the output in the debug window. You can then use a switch node to examine the output and do different things. Going back to my image at the top, the output of my smart switch is read, passed through a switch node and then lights are turned on or off accordingly.