As requested on this thread
Here’s how to receive data from Zigbee devices using emonHub on an emonPi
Hardware Required
- Sonoff 3.0 USB Zigbee receiver CC2652P (CC2652P Chipset)
- Zigbee Sensor, tested with Sonoff Zigbee temp sensors SNZB-02 & SNZB-02D
1. Setup receiver dongle
Code name: ZBDongle-P
Chipset: CC2652P
Other supported adaptors: Supported Adapters | Zigbee2MQTT
Flash coordinator FW
$ docker run --rm --device /dev/ttyUSB0:/dev/ttyUSB0 -e FIRMWARE_URL=https://github.com/Koenkk/Z-Stack-firmware/raw/master/coordinator/Z-Stack_3.x.0/bin/CC1352P2_CC2652P_launchpad_coordinator_20230507.zip ckware/ti-cc-tool -ewv -p /dev/ttyUSB0 --bootloader-sonoff-usb
Requires libseccomp 2.4.2.
, check version with dpkg -l | grep libseccomp
See: ERROR: Download of firmware was not successful · Issue #4 · git-developer/ti-cc-tool · GitHub
Full instructions Flashing the firmware via cc2538-bsl | Zigbee2MQTT
2. Install ZigbeeMQTT on emonPi
Follow guide: Docker | Zigbee2MQTT
If running Debian Buster :
Need to install libseccomp2
:
sudo apt-key adv --keyserver hkps://keyserver.ubuntu.com:443 --recv-keys 04EE7237B7D453EC 648ACFD622F3D138
echo "deb http://httpredir.debian.org/debian buster-backports main contrib non-free" | sudo tee -a "/etc/apt/sources.list.d/debian-backports.list"
sudo apt update
sudo apt install libseccomp2 -t buster-backports
See guide: Docker | Zigbee2MQTT
3. Configure zigbee2mqtt
wget https://raw.githubusercontent.com/Koenkk/zigbee2mqtt/master/data/configuration.yaml -P data
Edit config
$ docker run -d \
--name zigbee2mqtt \
--restart=unless-stopped \
--device=/dev/ttyUSB0:/dev/ttyUSB0\
-p 8080:8080 \
-v $(pwd)/data:/app/data \
-v /run/udev:/run/udev:ro \
-e TZ=Europe/London \
koenkk/zigbee2mqtt
Example Config
homeassistant: true
permit_join: false
mqtt:
base_topic: zigbee2mqtt
server: mqtt://192.168.86.24
user: pi
password: emonpimqtt2016
serial:
port: /dev/ttyUSB0
frontend: true
advanced:
homeassistant_legacy_entity_attributes: false
legacy_api: false
legacy_availability_payload: false
device_options:
legacy: false
devices:
'0x00124b002919285f':
friendly_name: temp1
RasPi Config
# Home Assistant integration (MQTT discovery)
homeassistant: false
# allow new devices to join
permit_join: false
# MQTT settings
mqtt:
# MQTT base topic for zigbee2mqtt MQTT messages
base_topic: zigbee2mqtt
# MQTT server URL
server: 'mqtt://172.17.0.1'
# MQTT server authentication, uncomment if required:
user: emonpi
password: emonpimqtt2016
frontend: true
# Serial settings
serial:
# Location of CC2531 USB sniffer
port: /dev/ttyACM0
Run
docker run -d --name zigbee2mqtt --restart=unless-stopped --device=/dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0:/dev/ttyACM0 -p 8080:8080 -v $(pwd)/data:/app/data -v /run/udev:/run/udev:ro -e TZ=Europe/London koenkk/zigbee2mqtt
Example output
Topic: zigbeemqtt/temp1
Payload: {"battery":100,"humidity":80,"temperature":22,"voltage":3100}
Use zigbeemqtt frontend to pair new zigbee device, frontend should be available on port 8080
Pair device (without frontend)
It’s also possible to pair a device using MQTT commandline
Message: zigbee2mqtt/bridge/request/permit_join
Payload: {"value": true, "device": "LCD_Temp, "time": 20}
e.g
mosquitto_pub -h bob -u pi -P emonpimqtt2016 -t zigbee2mqtt/bridge/request/permit_join -m '{"value": true}'
New device pairing will be announced on this topic
zigbee2mqtt/bridge/event
Then the device can be given a friendly name in /data/configuration.yaml
Restart zigbeemqtt
After editing config, restart by sending an empty message to: zigbee2mqtt/bridge/request/restart
4. Configure emonHub
Switch to emonHP JSON branch: MQTT JSON subscribe by glynhudson · Pull Request #198 · openenergymonitor/emonhub · GitHub
These steps shouldn’t be required once this PR is merged
cd /opt/openenergymonitor/emonhub
git pull origin master
git checkout mqtt_subscribe
git merge master
Example emonHub config:
[[MQTT_sub1]]
Type = EmonHubMqttInterfacer
[[[init_settings]]]
mqtt_host = 127.0.0.1
mqtt_port = 1883
mqtt_user = pi
mqtt_passwd = emonpimqtt2016
[[[runtimesettings]]]
pubchannels = ToEmonCMS,
node_JSON_enable = 1
node_JSON_basetopic = zigbee2mqtt/temp1