Hass.io: deCONZ, Phoscon, ConBee II

Hass.io: deCONZ, Phoscon, ConBee II


Forced Manual Firmware deCONZ Update ConBee II

Important:
Remove additional USB Z-Wave Mini Adapter stick from another USB port, or update will fail

In elevated Hass.io terminal, try this:

# Download, run and log into container
docker run -it --rm --entrypoint "sh" --privileged --cap-add=ALL -v /dev:/dev -v /lib/modules:/lib/modules -v /sys:/sys deconzcommunity/deconz

# Inside container
./firmware-update.sh -t 120 -d /dev/ttyACM0 -f deCONZ_ConBeeII_0x26780700.bin.GCF

# If success, remove container leftovers
docker rmi deconzcommunity/deconz

… or you could try this, but I haven’t tried it:

docker run -it --rm --device=/dev/ttyUSB0 --privileged --cap-add=ALL -v /lib/modules:/lib/modules --entrypoint "/firmware-update.sh" marthoc/hassio-addon-deconz-armhf

More info here: hassio-addons/FIRMWARE-UPGRADE.md


deCONZ REST API

For detailed instructions, check out the official site and the detailed PDF guide, and there is also the Phoscon App manual here.

If you need a detailed debug log for deCONZ, the quickest way for me was to open the deCONZ app and click Help. After that, click Debug View. The following debug levels need to be enabled for proper logging: INFO, INFO_L2, ERROR, ERROR_L2, APS, APS_L2.

Configuring Sensors Using the HA Service deconz.configure

I had to calibrate one Tuya hygrometer and it can be done in two ways, through deCONZ REST API or by calling the HA service “deCONZ configure”.

Everything is nicely explained here: Calibrating temperature sensors using the deCONZ service

Go with Home Assistant > Developer Tools > Services, select deconz.configure and Go to YAML Mode > Fill example data and then replace the values with real ones.

service: deconz.configure
data:
  entity: sensor.tuya_lcd_humidity
  field: /config
  data:
    offset: 10
  bridgeid: 00212EFFFF053872

Finding documentation was not easy, but [this article in Italian](https://indomus.it/guide/configurare-a-piacimento-componenti-zigbee-tramite-home-assistant-via-de conz/) helped, as well as the deCONZ REST-API documentation regarding supported /config attributes.

But I couldn’t find an easy way to discover the “Bridge ID”. And finally I realized that I can do it through REST API, but then it would be pointless since I had to go through the entire API process.

curl -s -X GET http://172.30.33.3:40850/api/FA341B5D14/ | jq '.' | grep "bridgeid"
> "bridgeid": "00212EFFFF053872",

Anyway, I found out that the proposed “example” value for “Bridge ID” in “service: deconz.configure” really had nothing to do with real value. And I executed everything else quite well actually.

The current value for some sensor can easily be checked with the API:

curl -s -X GET http://172.30.33.3:40850/api/FA341B5D14/sensors/67 | jq '.'

Configuring Sensors Using the deCONZ REST API

First, We Need an API Key

We can find the internal IP address of our deCONZ docker container from within HA from the deCONZ application through VNC, as explained here: Using deCONZ Zigbee REST API for adjusting sensitivity of Aqara Vibration Sensor

I don’t understand how, but I can also get the IP address from https://phoscon.de/discover.

And yes, it’s the same, IP: 172.30.33.3, port: 40850. Which I really don’t get?

We can access this address only “internally” from an SSH terminal on the RPi3, since this is the IP address of the docker container running the deCONZ API.

curl -s -X POST -d '{"devicetype": "terminal"}' http://172.30.33.3:40850/api/

Before that, we must unlock deCONZ for authentication, which we do from the Phoscon app, then Gateway, then Advanced, then ‘Authenticate app’, as explained here: Unlock the gateway

And then I got this:

[{"success":{"username":"FA341B5D14"}}]#

And that’s my API key for further work.

We Need the Sensor ID

To calibrate the device, we need the Entity ID from deCONZ, and we’ll get that by listing out all the sensors and inferring the ID from the sensor name.

# /api/<apikey>/sensors
curl -s -X GET http://172.30.33.3:40850/api/FA341B5D14/sensors

# same thing, but nicer
curl -s -X GET http://172.30.33.3:40850/api/FA341B5D14/sensors | jq '.'

In my case, the two-digit number assigned to my sensor was 67. Everything after that was easy, but I’m sure you can see the point once you’ve seen the output from the earlier commands.

Updating Sensor Values

So, the API endpoint request URL looks like this:

http://<ip>:<port>/api/<api-key>/sensors/<sensor-id>

So mine looks like this:

curl -s -X GET http://172.30.33.3:40850/api/FA341B5D14/sensors/67

At the end, to modify the offset value:

curl -H 'Content-Type: application/json' -X PUT -d '{"offset": 10}' http://172.30.33.3:40850/api/FA341B5D14/sensors/67/config

If you get {"success":{"/sensors/67/config/offset":10}}, that’s it.

Offset Units Aren’t What You’d Expect

Have you ever waited for hours only to find a strange comment in a support thread? That’s exactly what happened to me. In the support thread here I noticed the comment: “config.offset is in 0.01°C, just like state.temperature”. I was confused, but once I checked the humidity value, it all made sense.

When I ran the command:

curl -s -X GET http://172.30.33.3:40850/api/FA341B5D14/sensors/67 | jq '.'
> "humidity": 3511

Exactly, I got the result humidity: 3511. That meant that in order to increase the humidity reading by 5%, I had to set the offset to 500.

At this point it all seemed logical, but I wouldn’t have figured it out without the help of the person in the thread. I’d probably be quite upset at this point.

Maybe This Was Pointless Since Changes Don’t Show Up on the Device’s LCD Screen

I thought that the changes would take some time to be visible, but I was wrong. The changes were visible right away in Home Assistant.

However, they would never be visible on the device itself, which had a LCD screen.

Oh well, it was still a good lesson.


date 29. Jan 2023 | modified 31. Jan 2023
filename: Hass.io » deCONZ