Deconz in Docker - martikainen87/Home-Automation GitHub Wiki
Update - Hass.io addon!
Finaly there is a supported hass.io addon! Migrating from "my" solution to hass.io was simple, follow the steps in the guide, and give it some time to load everything up!
https://github.com/marthoc/hassio-addons
Read the instructions you see inside the hass.io add-on menu, because the github is almost empty.
Update - Migrating data to hass.io addon
I found that the phoscon backup/restore missed a lot of lights for me, therefore I used a manual backup
turn off the hass.io addon and also the deconz installation on your old server
Copy these files, it may vary where you've put them
config.ini
session.default
zcldb.txt
zll.db
Place them here on your new server
/usr/share/hassio/addons/data/69bb46cb_deconz/.local/share/dresden-elektronik/deCONZ
Start the deconz addon
Update firmware on the USB stick
Disconnect all USB devices except for the conbee stick. Stop the deconz addon
Execute these commands on the docker host
docker run -it --rm --entrypoint "/firmware-update.sh" --privileged --cap-add=ALL --device=/dev/ttyUSB0 -v /lib/modules:/lib/modules -v /sys:/sys marthoc/deconz
Press C for Conbee Choose device Copy and paste the filename, it's the one with the F in it.
Firmware available for flashing:
deCONZ_Rpi_0x261f0500.bin.GCF
deCONZ_Rpi_0x26210500.bin.GCF
Enter the firmware file name from above, including extension,
or press Enter now to exit.
File Name : deCONZ_Rpi_0x261f0500.bin.GCF
Press Y and wait for it to finish, then start the deconz addon and reattach your other USB devices.
How to run deconz on a docker system
I'm using Joch's code to run my container, I still want to manage it myself and therefore I've copied his dockerfile into my own system and building it locally.
The different versions for deconz can be found here: https://www.dresden-elektronik.de/deconz/ubuntu/beta/ If you want a new release, just change the version number in the dockerfile to the latest one.
Create a directory for the deconz file and the Dockerfile
cd /Docker
sudo mkdir deconz
Create the Dockerfile
sudo nano Dockerfile
Go to the Dockerfile page on Joch's repository at dockerhup and copy the code Paste it in the dockerfile and hit "Ctrl+x" and "y" and "Enter" to save it
Build the image
docker build -t deconz_homemade .
Using your old configuration
If you've previously had deconz installed on another server or as an regular installation (not docker) you can copy the database etc and you'll have all your devices accesible in the container.
there are 5 files you should copy
- config.ini
- deconz.tar.gz
- session.default
- zcldb.txt
- zll.db
Place them in /Docker/deconz
Running the container
Create a container for it, be sure to see if joch's has update the start code, the only difference we are applying is that we're telling docker to use "deconz_homemade" instead of "joch/deconz" to run our own image.
docker run -d --name="deconz" --net="host" --restart=always -e TZ="Europe/Berlin" -p 8080:8080/tcp -v "/Docker/deconz":"/root/.local/share/dresden-elektronik/deCONZ":rw --device /dev/ttyUSB0:/dev/ttyUSB0 deconz_homemade
The container will start automatically and you can test it by opening http://yourip:8080 and you will open the old webpage for deconz Or http://yourip:8080/pwa to use the phoscon app, It's really nice in the later versions and you can add xiaomi sensors, lights etc in it.
Upgrade Deconz to new version
To upgrade to the latest version
Start with stoping your current deconz container
docker stop deconz
Create a backup of your curren't data folder
sudo mkdir /Docker/deconzbackup/
sudo cp -a /Docker/deconz/. /Docker/deconzbackup/
And verify that the files where copied.
Modify the Dockerfile to get the latest version available, find the relevant version here
sudo nano /Docker/deconz/Dockerfile
Find the line that says ENV DECONZ_VERSION 2.05.05 and update it to the latest number
Remove the old container and the old image
docker rm deconz
docker rmi deconz_homemade
Go to the deconz folder again
cd /Docker/deconz/
Build the new image
docker build -t deconz_homemade .
Then create the new container
docker run -d --name="deconz" --net="host" --restart=always -e TZ="Europe/Berlin" -p 8080:8080/tcp -v "/Docker/deconz":"/root/.local/share/dresden-elektronik/deCONZ":rw --device /dev/ttyUSB0:/dev/ttyUSB0 deconz_homemade
open the phoscon app and verify that your configuration is working, your devices will be automatically added as soon as they report their status, some devices can take several hours and some devices will need to be rescanned. I have almost 90 sensors and most often 1 or 2 needs to be rescanned).
Uppgrading the firmware
If you go to the settings -> Gateway page in phoscon there will be a notification that you can update your firmware. Manually copy the ID for the upgrade, it should look like something this "0x261e0500". If the firmware shows 000000 for the firmware we need to go into the deconz container and obtain correct firmware
Open the container terminal
docker exec -it deconz bash
cd usr/share/deCONZ/firmware/
ls -l
You'll probably see two files
root@Dockerhost:/usr/share/deCONZ/firmware# ls -l
total 248
-rw-rw-r-- 1 1000 1000 126138 Feb 11 15:38 deCONZ_Rpi_0x261e0500.bin.GCF
-rw-rw-r-- 1 1000 1000 126202 Mar 24 15:53 deCONZ_Rpi_0x261f0500.bin.GCF
The last one has the newest date and we'll use that one.
exit the container
exit
kill deconz and run the upgrade
Docker stop deconz
sudo rmmod ftdi_sio
Change the upgrade number in the below code before running it (deCONZ_Rpi_XXXXXXX.bin.GCF)
docker run --rm -ti --privileged=true --device /dev/ttyUSB0:/dev/ttyUSB0 -v /dev/bus/usb:/dev/bus/usb deconz_homemade GCFFlasher_internal -d 0 -f /usr/share/deCONZ/firmware/deCONZ_Rpi_0x261f0500.bin.GCF
It will output something like this:
/usr/bin/GCFFlasher_internal: 9: /usr/bin/GCFFlasher_internal: rmmod: not found
/usr/bin/GCFFlasher_internal: 10: /usr/bin/GCFFlasher_internal: rmmod: not found
GCFFlasher V2_11 (c) dresden elektronik ingenieurtechnik gmbh 2017/12/10
using firmware file: /usr/share/deCONZ/firmware/deCONZ_Rpi_0x261d0500.bin.GCF
reset via FTDI
flashing 123252 bytes: |=============================|
verify: ....
SUCCESS
/usr/bin/GCFFlasher_internal: 14: /usr/bin/GCFFlasher_internal: modprobe: not found
/usr/bin/GCFFlasher_internal: 15: /usr/bin/GCFFlasher_internal: modprobe: not found
When it's done you need to exit the ftdi:sio function
sudo modprobe ftdi_sio
And then start deconz again
docker start deconz
Now go back to phoscon and verify that you are running the latest versions!