Adding Zigbee devices to HomeKit
Posted
One day, all home automation devices will just talk to each other. That day is not today. Until then, how best to get Zigbee devices to show in HomeKit?
There is a lot to like about Zigbee, especially compared to the older generation of HomeKit: The devices don’t consume IP addresses, can’t talk to the Internet and can have a lower power profile (so battery power is more viable).
But, I don’t want a whole bunch of apps and bridges to manage the devices and have to explain to my family. What I want is everything to show up in HomeKit, which the family know how to use. In this post, I’ll explain the route I took.
Essentially, there are four components to the solution:
- Hardware to bridge Zigbee protocol to your device
- Zigbee2MQTT to manage the devices, running on something that can run Node.JS
- A MQTT broker to publish control messages. Zigbee2MQTT likes Mosquitto
- HomeBridge to talk to your Apple devices with the z2m plugin
The latter three can all be installed on the same device. You want something that is always available. I used a Raspberry PI. Install instructions for each package can be found on their respective sites.
To bridge Zigbee traffic, I used an SMLight SLZB-06 because it supports Power over Ethernet and is designed in Ukraine. If you use DHCP, remember to reserve an IP address in your router: Zigbee2MQTT needs to know the IP address of the adapter. The device will generate a configuration for you
Once you’ve installed Mosquito and Zigbee2MQTT, edit the configuration for the latter and add the serial section. Your configuration.yaml should end up looking something like this:
homeassistant: false
permit_join: true
mqtt:
base_topic: zigbee2mqtt
server: mqtt://localhost
keepalive: 60
reject_unauthorized: false
version: 4
include_device_information: true
serial:
port: tcp://192.xxx.yyy.zzz:6638
baudrate: 115200
disable_led: false
advanced:
network_key:
transmit_power: 20
log_level: debug
homeassistant_legacy_entity_attributes: false
legacy_api: false
legacy_availability_payload: false
frontend: true
This is assuming you’ve installed Mosquitto on the same device, hence the mqtt://localhost
line.
Once you’ve started up Zigbee2MQTT, navigage to the Web UI and start pairing devices. A large range of devices are supported out of the box. If your device isn’t, it’s pretty easy to develop a converter. Any paired devices will show in the main UI:
Click on a device to see the controls and data it exposes:
Once all the devices are configured, install Homebridge, click on the plugins tab and search for zigbee2mqtt. Choose the verified plugin “Homebridge Zigbee2MQTT”:
Click setings and configure the topic and server. Assuming you’re running Homebridge, Zigbee2MQTT and Mosquitto on the same device, server will be localhost:
If everything is talking, you’ll see your zigbee devices show up on the accessories tab:
Finally, add Homebridge to your Apple Home environment to control devices from your Apple devices:
Tips
- If you have battery Zigbee devices a couple of powered devices will greatly improve network stability as their radios are higher power and the devices will act as routers. I used Philips Hue bulbs.
- Some Zigbee devices support over-the-air updates. Whether OTA is supported by Zigbee2MQTT varies. For instance Somfy don’t publish any details on their blind motors so I haven’t been able to figure out how to apply OTA updates to them in the converter I wrote.
- You can group devices in Zigbee2MQTT but my experience is grouping seems more reliable in the Apple Home app.