Sonoff have a Zigbee bridge, this bridge can be flashed using the Tasmota firmware which removes the reliance on the external servers for controlling devices and reporting states. It’s a bit like the Conbee II USB device in that way, but it was one advantage. Because it’s not USB based, it’s actually WiFi based, the Zigbee coordinator can be placed anywhere in the house, much more central, and as much as I don’t want a thousand and one hubs around the house, this does look a little neater than the random USB pen drive that is plugged in via an extension cable so that it is outside of the rack. Another advantage is because I run it all in ESXi, I have to pin the guest to a host due to the USB dependency, moving to a network based coordinator removes this dependency and allows the guest to move between hosts, providing more redundancy.
By doing this, I will also create a development/test/demonstration Home Assistant and Zigbee set up. The Sonoff bridge is relatively cheap and because it doesn’t rely on USB it’s easy enough to add another Home Assistant VM which will then use the secondary Sonoff device. This secondary instance will make life easier for creating videos and blog posts without having to worry about blurring out information or accidentally disclosing information.
Before I did any of this, I thought I would check a few things out with the Sonoff/eWeLink app. In the video about unboxing the Sonoff door sensor, I mentioned I had one that was draining batteries within a couple of days. I also have one that just stops reporting states, as if it won’t wake up. One of the things I wondered was if it was a firmware issue and maybe there was a new firmware available. So before flashing the hub with Tasmota, I fired up the app, registered for an account, added the hub, added the sensor to the hub and nothing. In the app there was no reference to firmware versions or updates. Shame. I was hoping there would be a firmware update to resolve these issues.
Something else I did was to also set up a pfSense firewall to try and look for the URLs that are used to check for firmware updates, adding a squid proxy to track any requests and try and work out where the OTA updates are served from. I was a little surprised to find it all running over HTTPS, which is a good thing! But this also made it difficult to try and trace the OTA paths and that is a bit of a dead end. Maybe I will revisit it in the future, we will see.
Tasmota is a custom firmware that is commonly used for providing local control of various IoT devices. It’s fairly common to apply Tasmota to LED controllers and other devices. Sonoff even provide a way to flash their basic device range with Tasmota by using a jumper!
There are a whole load of blog posts and YouTube videos detailing how to flash Tasmota on to the Sonoff Zigbee Bridge. I bought a USB TTY adapter and some bread pins, stripped the board out of the case, and the pins didn’t fit. Needless to say, I have a whole load of Cat5e cables around so I ended up sacrificing one for the cause. I used the internal cabling to connect the Sonoff Zigbee Bridge to the USB controller. Downloaded and ran Tasmotize and it really was as simple as the blogs made out. The whole process took 10 minutes. Fantastic.
Now the fun begins. Lets add the new controller to Home Assistant. OK, maybe not. You can only run one instance of ZHA within a Home Assistant server. This can only have one controller assigned to it. So you cannot run two Zigbee networks on one instance. Doh! So, now I am going to have to remove the integration, re-add it with the Sonoff controller and re-pair all the devices. I figured I would have to re-pair everything but I was hoping that I could do a migration with minimal downtime rather than a everything dead until it’s all redone. So, if this is a chance to address everything and actually do a design of the Zigbee network. Something I kinda wish I had done already. I have a draft blog post of things that I have learned whilst doing all of this which touches on this subject. But I will repeat/pre-seed it here.
One of the beauties of using the Sonoff device over the Conbee II is that I can position it anywhere in the house so long as there is somewhere that can provide USB power. Ideally this will be in the middle of the house. I am going to place mine in a place which is furthest away from a WiFi access point and very little in the way of electrical devices. It’s not in the centre of the house, but as I am not covering a huge expanse of an area, I am hoping this will be fine.
There is a really good document by Control4 on designing a Zigbee network. I have read through this and formed a plan. I know where I will be placing the coordinator, so I am trying to work out which channel gives the best option. Zigbee shares the 2.4GHz airpsace as the 2.4Ghz WiFi. I am already running Ubiquti Unifi which does show neighbouring WiFi networks, which channel they are on and which AP detected them. I am currently running 3 WiFi access points and already using all 3 of the 2.4GHz WiFi channels. After looking at all this, I will try running on Zigbee Channel 25. Although this is on the edge of Channel 11, looking on Unifi, my WiFi has one AP on this channel, and only one other network is seen internally (majority are outside) on this channel. I would aim for channel 26 but I believe that some devices don’t support this. So we will see.
Zigbee (and Zwave) both build a mesh network, generally using mains powered devices as additional routers to improve coverage. With this in mind, I am going to add all my wired devices first. Leave it for an hour or so to build the mesh then go around and add all the battery devices. It may or may not make a difference, but in my mind it is a logical approach (get the “infrastructure” in place first).
After everything is back on Home Assistant, it will be time to go through and check everything. Make sure that the automations are still triggering from the correct entities. Make sure all the dashboards are showing the correct entities, groups of lights are all rebuilt (there are only 3). I know I only have 24 (23 with the Sonoff sensor killing batteries) devices but this will be a PITA. But, at least it’s now I am switching over and not later.
So, after all the work above, I can see in ZHA that there is a nice mesh built with all of the mains powered devices acting as routers. The battery devices have all connected and it all looks better than it did with Conbee II. It has been a faff running round and re-pairing everything up but hopefully it was worth it. We will see what the performance is like but everything seems to be doing well so far. Switching over from Conbee II to Sonoff with Tasmota hasn’t fixed the front door sensor. It still just stops responding. The back door sensor battery level plummeted from 64% down to 10% but is slowly climbing back up. Think I will definitely be switching out the Sonoff door sensors to AQARA ones, given how well the temperature/humidity and motion sensors work.
I have noticed that the Tasmota firmware doesn’t operate the lights on the Sonoff bridge “as designed”, i.e. with the blue to indicate power and the green to indicate activity. It looks like it can do something when using MQTT but that’s not the route I want to go down.
One thing I didn’t do that I should have is delete the zigbee.db file. After removing the integration tied to the Conbee II, I should have removed the file. This left a few rogue entries in the device/entity list. I have since removed the integration, deleted the zigbee.db file and re-added and re-paired all the devices. Seems much happier now.