{"id":124,"date":"2021-02-11T19:51:43","date_gmt":"2021-02-11T19:51:43","guid":{"rendered":"https:\/\/andrejacobs.org\/?p=124"},"modified":"2022-04-11T20:24:24","modified_gmt":"2022-04-11T20:24:24","slug":"home-automation-with-xiaomi-aqara-zigbee-sensors-raspbery-pi-and-phoscon-conbee-ii","status":"publish","type":"post","link":"https:\/\/andrejacobs.org\/home-automation\/home-automation-with-xiaomi-aqara-zigbee-sensors-raspbery-pi-and-phoscon-conbee-ii\/","title":{"rendered":"Home Automation with Xiaomi Aqara Zigbee Sensors, Raspbery Pi and Phoscon Conbee II"},"content":{"rendered":"\n
I decided to dabble a bit with home automation and for the time being I am more interested in first getting an idea of the different temperatures and humidity readings around my house.<\/p>\n\n\n\n
My plan is to also use water leak sensors to detect if the upstairs bath, shower and even the boiler might spring a leak in the future.<\/p>\n\n\n\n
For the Zigbee gateway I decided to go down the Phoscon Conbee II route connected to a Raspberry Pi running Home Assistant and my main reason is that I want full control and trust in where my data is being sent to. This also gives me more flexibility to install other devices like Sonoff \/ ESP modules.<\/p>\n\n\n\n
Special mention goes to Trutz Fries’ tutorial<\/a> that I followed to get started in this.<\/p>\n\n\n\n I followed the official guide<\/a> for installing Home Assistant and downloaded the “Raspberry Pi 3 Model B and B+ 64-bit” image.<\/p>\n\n\n\n I used balenaEtcher<\/a> to install the image “hassos_rpi3-64-5.10.img.xz” to the 64GB microSD card.<\/p>\n\n\n\n Interestingly enough I ran into an issue with the microSD card and adapter on my Mac which I have not encountered before. For some reason the SD card kept showing up as being locked even though the adapter is in the unlock position.<\/p>\n\n\n\n After trying a couple of things I noticed that even though I put the lock slider in the unlock position, when I insert the SD adapter into my Mac it somehow gets pushed halfway towards the lock position.<\/p>\n\n\n\n Borrowed my son’s Raspberry Pi 400 adapter and had no more issues for writing to the microSD.<\/p>\n\n\n\n Although I have a good WiFi mesh network in my house running off Amazon’s Eero devices<\/a>, for this project I will be connecting the Raspberry Pi directly to an ethernet connection running from my “boiler room” (a.k.a the Server room) down to my broadband router. The idea being that in the near future I can get my local firewall back up and running again and can have finer control over devices like this.<\/p>\n\n\n\n For some reason you can not setup the WiFi on Home Assistant using the Web interface and have to resort to using a flash disk and rebooting the Raspberry Pi. Not a problem for me since I will only be using the ethernet connection, however the official guide<\/a> will give you instructions on how to setup WiFi.<\/p>\n\n\n\n I inserted the microSD card, connected the Raspberry Pi to the ethernet network (which I also knew was connected to the internet) and then connected it to the power supply. Home Assistant will boot and take quite a bit of time installing things.<\/p>\n\n\n\n To verify that the Raspberry Pi is connected I just pinged homeassistant.local<\/p>\n\n\n\n To access the Web interface just open http:\/\/homeassistant.local:8123\/<\/a>. Alternatively you will need to find the IP address of the connected Raspberry Pi (check your Router \/ DHCP provider \/ nmap scan).<\/p>\n\n\n\n Now is a good time to go get some coffee and plan where you want to place the sensors.<\/p>\n\n\n\n After a while Home Assistant will be ready to continue the setup process.<\/p>\n\n\n\n Continue setting up Home Assistant and check the status<\/a> of your system.<\/p>\n\n\n\n Before connecting the Conbee II it is a good idea to get the list of current serial devices so that when you plug the Conbee II in you can easily spot which device it is mapped too.<\/p>\n\n\n\n Navigate to Supervisor, System, Host and then select the menu (3 dots) and then Hardware.<\/p>\n\n\n\n I searched for “tty” and looked for a device like this<\/p>\n\n\n\n Next I plugged in the Conbee II to the Raspberry Pi using the USB extension cable and rebooted the Raspberry Pi (Reboot Host on that same page). It is recommended by Phoscon (makers of Conbee II) to use an extension cable to minimise interference to the device.<\/p>\n\n\n\n Once Home Assistant has rebooted I went back to look at the available devices and searched for “tty” again and this time I found the following device.<\/p>\n\n\n\n Make note of the dev_path and by_id portion. I will be using by_id for setting up deCONZ<\/p>\n\n\n\n Navigate to Supervisor, Add-on Store and search for “deconz”.<\/p>\n\n\n\n Select the deCONZ add-on and install it. This will take a few minutes.<\/p>\n\n\n\n Once the add-on has been installed you need to go to the Configuration tab and select “Edit in YAML” by using the 3 dot menu.<\/p>\n\n\n\n For the device value I entered (with qoutes) “\/dev\/serial\/by-id\/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2250706-if00” and the interface will show it like this.<\/p>\n\n\n\n Save and go back to the Info tab. I turned on “Start on boot”, “Watchdog” and “Show in sidebar”.<\/p>\n\n\n\n Start deCONZ add-on and if it starts up correctly you will notice a green dot at the top right.<\/p>\n\n\n\n Now you can configure the Conbee II by selecting “Open Web UI” and selecting Phoscon. I setup the connection by selecting the Phoscon-GW device and setting a login password.<\/p>\n\n\n\n Since I will not be setting up any Phoscon lights I just select Proceed without lights. You will also be asked to create your first group. For the moment I just created my first group with the name “Testing”.<\/p>\n\n\n\n I ordered 15 of the Xiaomi Aqara Temperature and Humidity Sensor<\/a> and 3 of the Xiaomi Aqara Water Leak Sensor<\/a> from Banggood<\/a> and they were shipped from China to the UK.<\/p>\n\n\n\n I paid \u00a38.27 each for the temperature and humidity sensor and \u00a314.14 each for the water leak sensor on the 14th of January 2021. Banggood turned out to be a very good choice because buying the temperature sensor from a UK supplier after Brexit would have been just under \u00a318 a unit!<\/p>\n\n\n\n The sensors arrived in a very good condition and as can be seen in the next photo they are packaged very well.<\/p>\n\n\n\n The sensors were smaller than I expected and this is a big bonus in my book.<\/p>\n\n\n\n They are operated on a CR2032 coincell battery and should hopefully run for about 2 years before needing to be replaced.<\/p>\n\n\n\n Be careful<\/strong> opening the temperature and humidity sensor because it only needs a very small turn to unlock it (I am guessing about 5 degrees) where as the water leak sensor takes a number of turns.<\/p>\n\n\n\n I will be connecting the Xiaomi Aqara Temperature and Humidity Sensor<\/a> sensor first. This sensor also measures barometric air pressure.<\/p>\n\n\n\n While still on the Web UI for deconZ, navigate to the Hamburger menu and select Sensors.<\/p>\n\n\n\n Add new sensor and select Other for the vendor.<\/p>\n\n\n\n Briefly press the button on the top of the sensor and after a few seconds you will see the message that the Sensor is ready. Note. If you need to reset the sensor (in my case it was previously setup) then you just hold down the button until the led starts flashing blue.<\/p>\n\n\n\n You can select the sensor from the list and it will give you more information.<\/p>\n\n\n\n You can also rename the sensor. In my case since I have 15 temperature sensors this would be a good idea!<\/p>\n\n\n\nHardware and Software used<\/h2>\n\n\n\n
<\/li>
<\/li>
<\/li>
Installing Home Assistant<\/h2>\n\n\n\n
SD card adapter issue<\/h3>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure><\/div>\n\n\n\n
Flash and Boot<\/h3>\n\n\n\n
<\/figure><\/div>\n\n\n\n
$ ping homeassistant.local\nPING homeassistant.local (192.168.4.27): 56 data bytes\n64 bytes from 192.168.4.27: icmp_seq=0 ttl=64 time=4.140 ms<\/code><\/pre>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure><\/div>\n\n\n\n
Setting up the Conbee II<\/h2>\n\n\n\n
<\/figure><\/div>\n\n\n\n
- name: ttyAMA0\n sysfs: \/sys\/devices\/platform\/soc\/3f201000.serial\/tty\/ttyAMA0\n dev_path: \/dev\/ttyAMA0<\/code><\/pre>\n\n\n\n
- name: ttyACM0\n sysfs: >-\n \/sys\/devices\/platform\/soc\/3f980000.usb\/usb1\/1-1\/1-1.4\/1-1.4:1.0\/tty\/ttyACM0\n dev_path: \/dev\/ttyACM0\n subsystem: tty\n by_id: >-\n \/dev\/serial\/by-id\/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2250706-if00<\/code><\/pre>\n\n\n\n
Installing deCONZ<\/h3>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure><\/div>\n\n\n\n
Unboxing the Xiaomi Aqara sensors<\/h2>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure><\/div>\n\n\n\n
Connecting the first sensor<\/h2>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure><\/div>\n\n\n\n
<\/figure><\/div>\n\n\n\n
Connecting the leak detector sensor<\/h3>\n\n\n\n