Deconz Integration couldn't retrieve API key

Hello,

I am trying to set up the deconz integration, but I am consistently getting the error:
Couldn’t retrieve API key

This is the case even though I am allowing in phoscon to authenticate apps.

I tried to get to the bottom of it and here are the steps I took:

  1. Run a post command via Postman (REST-API Client add on) in chrome
    Request to: http://192.xxx.xxx.xx:xxxx/api/
    Parameters: {“device type”:“Testkey”,}
    Result: "success: { “username”: "xxxxxx}

So this way I can retrieve an api key

  1. Run cUrl command:
    curl http://IP:PORT/api/ -X POST -d ‘{“devicetype”: “TestKey”}’
    Here I am getting the following error:
    [{“error”:{“address”:"/",“description”:“body contains invalid JSON”,“type”:2}}]

  2. Link deconz integration in homeassistant
    Manually configured host and port to ensure the correct settings are used.
    Unlock Gatewasy with “authenticate app” button
    Result: couldn’t get API key
    Another note: Homeassitant is proposing even the correct IP address of the gateway.

I am really wondering why I am able to retrieve an Api key with a rest-api client add on, but Homeassistant is unable to retrieve one.

Another workaround I tried was to add

deconz:
host: IP
port: PORT

to my configuration.yaml

I would appreciate any hint or support I can get from the community.

Thanks for your help!

How have you setup deconz? You don’t have firewall rules blocking requests?

Deconz is running in a separate container on a qnap NAS and my Homeassistant installation on a virtual machine.

The firewall isn’t blocking the connection.

I am not sure what happened, but all of a sudden I am able to get the integration back up and running.

It’s pretty weird as I didn’t really change anything on my setup.

First the deconz integration complained that tge gateway is not reachable and finally decided that the API key cannot be retrieved.

That’s when I deinstall Ed the integration and I was hoping a new set up integration will work fine again, but without any success.

Then I started looking closer into contacting the api with rest api add on which was working fine, but homeassitant still wasn’t able to retrieve the API key.

I am glad it’s back up running, but a bit disappointed I cannot really tell what the actual issue was.

Yes it would have been good to understand the root cause

Agreed - anyway thanks for your feedback! If I might still figure out the root cause I will post it here.

Have a good start into the new year and all the best for 2023

2 Likes

And the same to you

Hey mate. Did you figure this one out? Have the same issue now where deconz integration can’t get a valid api

Same here.

In the end I completely removed the integration and relinked it to my deconz application. Luckily the phoscom app saved all my info/devices so it was seemless to just set it up again

I think I might have found the issue. Or at least I found the issue for me.

In my docker compose for deconz I had:

ports:
- 8080:80
- 8443:443

When I clicked on the “go to device” button on the setup screen, it sent me to:

localhost:8090

I changed my port in my docker compose for deCONZ to 8090 instead of 8080, and it all just worked.

I had the same issue with my deconz docker container in Truenas Scale.

I also solved it by adding the Deconz Integration in Home Assistant manually, this time using the server IP (192.168.0.x) rather than the Node IP which Home Assistant had automatically detected (perhaps because in the container settings I had checked the box “use Node IP”).

1 Like