Adding Zigbee2MQTT to my "VanAssistant"?
By Rob Litjens
In my previous blogs about the VanAssistant i showed you that it is wise to assemble a nice good case around your Raspberry Pi. We configured that Raspberry PI with an m2 SSD in a NAS case. That case has room for ventilation, a fan and less important some nice lights.
The blog after that I configured a router to be used with the RaspberryPi. I opted for a RUTX50 from Teltonika. There is also a later option: RUTC50. Both seem to be similar but the latter has WiFi6e on board which give you also AC capabilities.
The third blog should go about setting up the RUTX50 to send out MQTT messages. The Router should be able to be a publisher but also Broker. As you may have read, I did not manage to get that working the way I wanted. I filed a ticket. After publishing my blog I got an answer. So, I wil get back to you with a follow up if that got to work.
The fourth blog, this one, will handle the installation of a Zigbee stick and use it with zigbee2mqtt.
Why Zigbee2MQTT?
Reason for me was that I want to have all, when possible, devices being controlled by MQTT. In fact, I want to have the broker running on the Router. That one is always on. This would also mean that I can connect an instance at home to the same router to find out where my camper is at that moment.
Zigbee2MQTT is widely integrated with a ton on Zigbee devices. It means it runs as a separate container on your Raspberry Pi. This is also the reason that I want the Router to be the broker. It means a litle d-tour for an action, but it would also mean that I could remove the Mosquitto broker from the Raspberry Pi. Not sure how it will end up, but lets get started.
What do you need?
Of course, a zigbee stick. At home I am using a ConBee II, for the VanAssistant I opted for a Sonoff Zigbee 3.0 USB stick, model P. There is also a model E. The latter supports Matter and Thread, but requires a lot more configuration (according the books)
Next to that, you should use a USB-A extension cable. Advice is 2 meters. This is because Zigbee interferes with USB signals comming from the RaspberryPi. Below there is more information on the why.
Lets start
For making MQTT work you need to create a user and you need to install a broker.
User creation
We created a user in the previous Blog, but it is easy to create. Go to your settings, select people, from the bar select “Users” and click on the “Add user” button in the corner of the right bottom. Display Name, Username and password are the only required fields. Do NOT switch administrator on. There is no need for this.
Broker installation
The Broker can be installed using Settings, Add-ons and then click on “Add-on store” Select Mosquitto and press install. Enable the Watchdog and technically you are good to go now.
Integration installation
When you have installed Mosquitto, you normally get the MQTT integration for free. If not, you will need to install it manually. The easy way is to go to the integrations, click on the “Add Integration” and then the installation starts. Configuration is just telling the broker is “Core-Mosquitto”, Port 1883 and then your username and password. Then you are almost done
Install Zigbee2mqtt
For this you need to download it from a repository not in the basic configuration. Therefore you should go to “Settings”, “Add-ons” and press the button “Add-on store” in the right bottom. That will bring up a page where you see 3 dots in the right top. Press on it and select “Repository”. Fill in “https://github.com/zigbee2mqtt/hassio-zigbee2mqtt" as the repository
Then you need to refresh your browser.
If you start searhing for zigbee2mqtt you will find 3 options:
The first one is the one we need. The Edge variant is the DEV version (next version) and the proxy is needed when you run Zigbee2MQTT on another device.
On the page that appears after selecting Zigbee2MQTT you need to press install. When this is done, you need to perform some configuration, which is obvious. Go to the configuration page and add the following under MQTT:
Insert your USB stick
Now it is time to insert the Zigbee stick in your Raspberry Pi.
Before we can use it we need to find out where it is installed.
Open a new browser by right clicking on settings and select "Open in new Browser"
You can do that by going to Settings, System, hardware and click “All Hardware”. In the searchbar type tty. This will show you all the usb connected hardware. Depending on the brand of Zigbee stick, you will find it here. Mostly ttyACM0 or 1.
If you have found your adapter, press the chevron at the end and copy the information in the ID:
Finalize the configuration by Going back to your Zigbee2mqtt window and type the following in the serial section: port: adapter: zstack
Press Save. Zigbee2MQTT will restart
Go back to the info tab and: Enable the watchdog Enable Show in Sidebar
Validate if Zigbee2MQTT is working
The easiest way to find out is to go to the log and see:
I get nervous about red errors. A quick investigation also shows the issue. I need to add mqtt:// in front of the servername (my example above is correct!).
Now that it seems to be running, I will install a simple sensor. I have opted for an Aqara Door and Window sensor. I will use these to find out if someone has left a door open in the campervan.
Setup the Sensor
After unboxing, pull the plastic that protects the battery from the device. Just above this plastic there is the paring button. Lets see what happens. Nothing… No auto pairing at this moment.
Ok. Go to Zigbee2MQTT in the left menu. You will see a bar on top:
Press Permit join.
On the device press the litle button at the bottom (if you keep it upside down it will be on top).
Almost immediately the device is found.
Going through this page, you will find out various nice features of this integration. You can rename the device to a meaningfull name(I renamed it to door sensor for the test but it will be left garagedoor later). The about page will tell you what type of device it is and some features The “exposes” tab will let you play with the various options of your device. In my case if I move the magnet away it will give the contact to be “Open”.
When i put the magnet next to the sensor it says close.
One of the reasons that I choose for this sensor is that I would love to know if a door stays open or closed. Especcially while driving
After testing I have attached them to the doors of my camper.
Next time
Now that I have the zigbee stick up and running, connected an Zigbee device, it is time to create something. I have litle Victron in my Camper, but not a BT adapter. We will do the full setup of it. Stay tuned!
Additional Information
Below you will find a list of used or updated sites, repositories and devices used in this blog or blogseries
Websites
Zigbee2MQTT.io Zigbee stability
Repository
Home Assistant Zigbee2MQTT integration
Devices
Below a list of devices I used. These link to Amazon, but are NOT affiliate links. They are just for informational usage.
(Sonoff Zigbee 3.0 USB stick)[https://www.amazon.nl/dp/B09KXTCMSC?ref=ppx_yo2ov_dt_b_fed_asin_title] (Aqara door and window sensor 3pc)[https://www.amazon.nl/dp/B09TP7VMKB?ref=ppx_yo2ov_dt_b_fed_asin_title]