I have recently been exploring Zigbee integration to Home Assistant.
My preference is to use a Zigbee-ethernet gateway, as this gives more flexibility compared to using a USB-Zigbee gateway.
I chose to use a ZB-GW03 flashed with Tasmota firmware.
When using a Zigbee-ethernet gateway, there are two main options for how the gateway can integrate into Home Assistant
- Zigbee2Tasmota (Z2T) with Tasmota & MQTT integration
- Zigbee radio ethernet serial bridge with ZHA.
ZHA - ethernet serial bridge - Zigbee radio
The ethernet serial bridge with ZHA is a good simple option as ZHA handles Zigbee device discovery and integration very well in a user-friendly way.
For reference here are some notes on how to set this up.
- Go to Configuration > Configure Template
- Change GPIO2 from Zigbee Tx to TCP Tx
- Change GPIO4 from Zigbee Rx to TCP Rx
- Console
- TCPStart 8888
- Rule1 ON System#Boot DO TCPStart 8888 ENDON
- Rule1 1
- HA > Add-on > Store > ZHA
- Set port to: socket://<zigbee_bridge_IP>:8888
However there are issues noted with packet loss and latency when using serial over ethernet which may cause some issues with the Zigbee protocol.
Zigbee2Tasmota - MQTT Integration
Zigbee2Tasmota (Z2T) is a light-weight gateway/bridge solution that can run on ESP devices. It handles all the Zigbee communication on the device, and then integrates to HA using the Tasmota and MQTT add-on. The solution is more robust and is not affected by network latency issues. However it does not handle device discovery for generic Zigbee devices, and these devices must be manually configured.
Here are some good resources for how to get this setup.
The small fix I’d like to suggest is regarding the MQTT Light integration.
Basically my suggestion is to add a state_command_template
configuration variable to allow both receiving the power state from the device and setting the power state from Home Assistant.
This is an example configuration for the Dimmer switch. This will allow you to set and receive brightness. It will allow you to receive power state, but not set power state.
light:
- name: "Dimmer"
command_topic: "cmnd/tasmota_EE3750/ZbSend"
state_topic: "tele/tasmota_EE3750/Dimmer/SENSOR"
state_value_template: "{{ value_json.ZbReceived['0x544F'].Power }}"
brightness_command_topic: "cmnd/tasmota_EE3750/ZbSend"
brightness_state_topic: "tele/tasmota_EE3750/Dimmer/SENSOR"
brightness_scale: 255
on_command_type: "brightness"
brightness_value_template: "{{ value_json.ZbReceived['0x544F'].Dimmer }}"
payload_on: 1
payload_off: 0
brightness_command_template: '{"device": "dimmer","send":{"Dimmer":{{ value | int }}}}'
Note there is a separate command variable for brightness_value_template
(which allows HA to receive brightness state from the device) and brightness_command_template
which allows HA to send brightness commands to the device.
The state_value_template gets the power state, and compares it to the payload_on and payload_off value to determine the power state of the device.
However if you want to send the power state you need to send '{"device": "dimmer","send":{"Power":1}}
to the command_topic.
There is currently no state_command_template
configuration variable to allow you do this.