Eversince I discovered ZigBee2MQTT Dashboard, I thought my experience with the framework managing all ZigBee devices couldn’t get any better. I have to mess about with the installation from time to time when testing new ZigBee devices sent to me. They are often not supported at launch, leaving me to figure out how to make a converter that “kinda works”. I went through the usual process last night, except this time it was much different!
Update!
Each time I add a new unsupported device to ZigBee2MQTT, I make sure my installation is up to date. I’d rather find the correct converter in the update than try to figure out things for myself. This process required several steps to backup the files, perform updates and…
It was simply annoying…
The recent installation (at least on my end) brought changes to how you update the ZigBee2MQTT. Now you can do that with a single line of code! What’s even better, you can schedule the task yourself and forget about it.
I’m aware that you could, in theory, make a DIY script which would execute the steps required before, but running the update file made by the developer is so much easier. Moving forward this is how you update your ZigBee2MQTT:
cd /opt/zigbee2mqtt
./update.sh
Or if you don’t want to mess about and like one-liners: /opt/zigbee2mqtt/update.sh
The script will also take care of pausing Z2M and resuming it after the update for you. If you don’t want to do it manually each time, you can simply use crontab to do this for you.
sudo crontab -e
Then add these 3 tasks to the desired schedule. If you want to customise your schedule in a very simple way, check out this generator online! In the sample below, I’m running my update script every week on Sunday:
0 3 * * 7 /opt/zigbee2mqtt/update.sh
Add the line to your file, and save it with Ctrl+X, Y. Then enjoy unattended updates. Bear in mind, that it’s wise to schedule a backup of your Z2M files, and you can do it by first removing the previous backup, and then copying the data folder:
#remove old back up and copy new files over
rm -r /backup/data
cp -r /opt/zigbee2mqtt/data /backup/data
Final Thoughts
It’s a small but very useful quality-of-life improvement. Add it alongside the two other most popular commands for your terminal sudo apt-get update && sudo apt-get upgrade -y
to always keep your system up to date. If you have any good tips for managing your home automation let me know in this Reddit thread.