Get API-key from phoscon/deconz

Thank you @afelix for this description:

I have this set up. You install Deconz on the same device, or another if you prefer. Running from docker-compose was the easiest for me. Once this runs, go into the Phoscon web interface -> advanced, and there should be something about third party access. Next, install the deconz nodes from the palette in node-red: https://flows.nodered.org/node/node-red-contrib-deconz

If you installed it from docker, it will include the rest API. The next step is adding a temporary part to your flow, or do it over curl instead if you prefer that. Set up an inject node on JSON input, based on the following: http://dresden-elektronik.github.io/deconz-rest-doc/configuration/#aquireapikey , then wire it to an http-request node set to your phoscon/deconz install, and the output to a debug node. Deploy, go back to the phoscon settings page and click the authenticate button, then inject on the flow and copy the api key from the debug sidebar.

Drag a deconz-event node into your flow and set up the configuration, pointing it to your Phoscon install. Set it up with the API key you just got. Since the API key setting up is just a one time thing you can remove the inject/request/debug thing again. If you deploy, the deconz-event will now give a message on every event deconz outputs, including but not limited to sensor values and battery levels of connected devices. Mine is currently set up with Innr lamps, and ikea trådfri/symfonisk remotes.

This post was a big push in the right direction for me. However I have tried numerous combinations of setups/inputs in my Node Red flow to acquire the API key from Phoscon with no luck so far. Can you (@afelix) or anyone else be more specific on what text goes where? It will be greatly appriciated. :pray:

The only output I get from my debug i something like this:

7.6.2020 15.04.01[node: 69ed4b83.a021e4](http://192.168.1.114:8123/api/hassio_ingress/b7r8nrb4ltZSvVUYVCYWYHjtdCQwoKcbDpb8FS-ZGO0/#)POST /api : msg.payload : string[63]

"Error: connect ECONNREFUSED 172.30.33.2:80 : http://172.30.33.2"

7.6.2020 15.04.01[node: Conbee II](http://192.168.1.114:8123/api/hassio_ingress/b7r8nrb4ltZSvVUYVCYWYHjtdCQwoKcbDpb8FS-ZGO0/#)msg : string[60]

"WebSocket error: Error: connect ECONNREFUSED 172.30.33.2:443"

7.6.2020 15.04.03[node: Conbee II](http://192.168.1.114:8123/api/hassio_ingress/b7r8nrb4ltZSvVUYVCYWYHjtdCQwoKcbDpb8FS-ZGO0/#)msg : string[60]

"WebSocket error: Error: connect ECONNREFUSED 172.30.33.2:443"

My flow setup variations of something like this:
Inject node:
Payload: { "username": "", "devicetype": "Phoscon-GW"}
Topic: POST /api
http request node:
Method: POST
URL: 172.30.33.2
Use authentication:
Type: basic authentication
User: Zigbee-GW
Password:*********
debug node:
default

The error you’re seeing means the deconz node can’t connect to your setup. Have you verified in your browser that on http://172.30.33.2:80 your phoscon setup is located? If not, edit the address so that it matches, and make sure the port is correct too.

Thank you for the quick response. I got it to work about 10 minutes ago + the time to write this post :wink:
The solution though, was quite different.

install node-red-contrib-deconz through Node Red palette
added a get node to my flow (Could be any deconz node I quess)
Setup server on this node (Press the pencil button in the nodes settings)
Added this:
Name: Conbee II
IP-Address: 192.168.1.114 (The address of Home Assistant)
Port: 40850
Websocket Port: 8081
Polling, sec: 15

Go to Phoscon in advanced settings and press Authenticate app
Inside 60 sec, go to Node Red and press Get settings inside your nodes settings
The API key appears in the text field.
The zigbee devices are still not to be found under devices
A restart of Home Assistant and all my zigbee devices are found in the list.

This is proberbly because of some updates this is possible. Sad that it took me about 36 hours to get here.
The ip adress I tried to use in the first place, is that ip in the top right corner in Phoscon. I thought that was the right one to use. I still have no idea how you got it to work though, but I very much appreciate you took the time to respond.

If I’m guessing, it’s the internal ip address on your machine within docker to communicate between containers.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.