Zigbee2MQTT

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Git updated, seems it's now supported?

https://github.com/Koenkk/zigbee2mqtt/issues/295
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Zigbee2MQTT

Post by EddyG »

No changes in github yet.
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Node-Red flow to unpair a device in Zigbee2MQTT

Code: Select all

[{"id":"881e4b14.568708","type":"mqtt out","z":"f962b96d.7044c8","name":"zigbee2mqtt/in","topic":"zigbee2mqtt/bridge/config/remove","qos":"","retain":"","broker":"cd51966f.aa7e38","x":480,"y":420,"wires":[]},{"id":"c60eb810.782768","type":"inject","z":"f962b96d.7044c8","name":"Device to Unpair","topic":"","payload":"0x001388020121e5ei","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":300,"y":420,"wires":[["881e4b14.568708"]]},{"id":"4eb439f3.01d7f8","type":"comment","z":"f962b96d.7044c8","name":"Unpair a Device","info":"","x":100,"y":420,"wires":[]},{"id":"cd51966f.aa7e38","type":"mqtt-broker","z":"","name":"Domoticz","broker":"192.168.0.5","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Instructions:

1) Click "Device to Unpair"
2) "Payload" should be the name of the device to unpair (can be found in configuration.yaml)
3) Click the little button to the left of "Device to Unpair"
4) Check configuration.yaml in /opt/zigbee2mqtt/data the device should be removed

https://github.com/Koenkk/zigbee2mqtt/w ... nfigremove

Also a note:

To pair a Philips Hue Lightstrip with the Hue Bridge after it's previously been paired with Zigbee2MQTT, the solution is to type the 6 digit SN code on the back of the lightstrip controller when adding via the Hue app.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Created an admin panel in Node-Red

https://github.com/ben423423n32j14e/zig ... adminpanel

screenshot.png
screenshot.png (283.06 KiB) Viewed 4806 times
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Zigbee2MQTT

Post by EddyG »

Nice work. :D
Hopefully this Zigbee solution can hardware wise be directly integrated in Domoticz.
Saves a lot of nodered programming.
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Indeed, unfortunately I don't currently have that level of skillset. :(

For me personally I don't see any reason why not to continue building on Node-Red, I like that I can integrate support for just about any Zigbee device that can join Zigbee2MQTT.

I'm creating a separate Git with flows for each type of device.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Zigbee2MQTT

Post by EddyG »

I am very curious for the flow of the Cube ( MFKZQ01LM - Xiaomi Mi smart home cube )
A whole lot of combinations. ;)
Dlanor
Posts: 67
Joined: Sunday 22 March 2015 16:18
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Zigbee2MQTT

Post by Dlanor »

I am trying to figure how to add devices. Does anyone have a step by step tutorial?
Domoticz| Zigbee | SONOFF
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

EddyG, have thought about the Xiaomi Cube (it's the only Xiaomi Zigbee sensor I don't currently have).

Would be cool in a 1 bedroom apartment type setup, I've got ZRC-90 remotes for each room with labelled buttons.

viewtopic.php?t=13782#p186794

My thinking RE the cube is I would forget what movement triggered x action, I'm very happy with the ZRC-90's.

Also have a few Aeotec Wallmote's setup as a panel in the kitchen which are fantastic.

viewtopic.php?f=24&t=16372&start=20#p172869

Hopefully my Xiaomi vibration / tilt/ fall sensors arrive today. :)
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

EddyG, are you finding that your Xiaomi Motion Sensors are not reporting battery status?

Also my Vibration / Tilt / Fall sensors finally arrived (today), will start playing with them soon.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Zigbee2MQTT

Post by EddyG »

Dlanor wrote: Sunday 09 September 2018 7:59 I am trying to figure how to add devices. Does anyone have a step by step tutorial?
Here is the pairing of devices: https://github.com/Koenkk/zigbee2mqtt/w ... ng-devices

@ben53252642 All of my battery devices are reporting the battery %, but some of them are still on 100%, but they are new.
On the cube on top there is Aquara logo, so you could start from there.
Flip 90 on 4 sides, flip 180, wakeup, shake. Every side has a number so json look like:

Code: Select all

object
battery: "100.00"
voltage: 3035
linkquality: 5
action: "flip90"
from_side: 0
to_side: 5
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Thanks EddyG, I will wait to see if the motion sensor eventually checks in with a battery status (it's not sending one each time motion is triggered).

Battery works fine for my Xiaomi Temp / Humidity sensor, it's been fluctuating from around 85 - 88%, seems to be effected by temperature I'm guessing since it's stuck on a metal surface.

3f534523rfds.JPG
3f534523rfds.JPG (40.15 KiB) Viewed 4588 times
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
MarFan
Posts: 18
Joined: Monday 02 September 2013 15:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Zigbee2MQTT

Post by MarFan »

First of all, really great dashboard! Thanks.
Do you think you can integrate a function like this https://github.com/Koenkk/zigbee2mqtt/issues/252?

I also hopes that an integration for Zigbee2MQTT will be in domoticz.
Somebody already start building it ? (maybe I can join)
MarFan / NL / 3x RasPi / RfXcom / RfLink / S0PCM-5 / P1
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

MarFan, current thinking is a bit different.

I'm working on adding a "Device Health" widget, that lists devices with low signal, low battery or have not been seen for more than 6 hours (potentially failed).
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Added support for Philips Hue Lightstrip Plus V2

https://github.com/ben423423n32j14e/zig ... er/devices

Note, lightstrip firmware cannot have been upgraded using a Hue Bridge. If it has you will need to wait until Z-Stack 3.0 is available for Zigbee2MQTT.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

EddyG, check this out,

Worked out how to use a variable for the MQTT topic.

A single flow that can control any Hue Lightstrip in the house (includes a HTTP API) so I can control using Lua scripts.

Eg:

Code: Select all

http://192.168.0.5:1880/hueapi?devicename=lightstripkittylitter&state=on&brightness=126&r=0&g=0&b=0&colortemp=366&transition=1

Code: Select all

[{"id":"fb7148f.58630b8","type":"comment","z":"ecbf4921.26b488","name":"Philips Hue Plus Lightstrips","info":"","x":150,"y":120,"wires":[]},{"id":"48eebee9.f9ecc","type":"mqtt in","z":"ecbf4921.26b488","name":"","topic":"domoticz/out","qos":"2","broker":"cd51966f.aa7e38","x":350,"y":60,"wires":[["a9756327.ccade"]]},{"id":"80a1c890.346428","type":"function","z":"ecbf4921.26b488","name":"Domoticz Control","func":"var idx = msg.payload.idx;\n\n// Domoticz IDX to Zigbee2MQTT Device Name Map\nif (idx == '1258'){\n    devicename = 'lightstrip2ndbathroommirror';\n} else if (idx == '1260'){\ndevicename = 'lightstripkittylitter';\n} else if (idx == '1261'){\ndevicename = 'lightstripmainbathmirror';\n} else if (idx == '1262'){\ndevicename = 'lightstripmbrwardrobe';\n} else {\n    devicename = null;\n}\n\nif (typeof devicename !== 'undefined' && devicename !== null){\n\nvar nvalue = msg.payload.nvalue;\nvar brightness = msg.payload.svalue1;\nvar r = msg.payload.Color.r;\nvar g = msg.payload.Color.g;\nvar b = msg.payload.Color.b;\nvar colortemp = msg.payload.Color.ww;\nmsg.payload = {}\n\nif(nvalue == '0') {\n    msg.payload.state = 'OFF'\n}\nif(nvalue == '1' || nvalue == '10') {\n    msg.payload.state = 'ON';\n    msg.payload.brightness = Math.round(brightness * 255 / 100);\n    if (r === 0 && b === 0 && g === 0) {\n    msg.payload.color_temp = Math.round(500 / 255 * colortemp);\n    msg.payload.transition = 1;\n    }else{\n    msg.payload.color = {\"r\":r,\"g\":g,\"b\":b};\n    msg.payload.transition = 1;\n}\n}\n\nmsg.topic = 'zigbee2mqtt/'+devicename+'/set';\n\nreturn msg;\n}","outputs":1,"noerr":0,"x":650,"y":60,"wires":[["f7ed5194.3f7f9"]]},{"id":"a9756327.ccade","type":"json","z":"ecbf4921.26b488","name":"","property":"payload","action":"","pretty":false,"x":490,"y":60,"wires":[["80a1c890.346428"]]},{"id":"772e44e0.eeb13c","type":"template","z":"ecbf4921.26b488","name":"page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n<head></head>\n<body>\n<h1>API:</h1>\n<h3>Usage: /hueapi?devicename=huetest&state=on&brightness=100&r=50&g=170&b=2&colortemp=0&transition=1</h3>\n<h3>or</h3>\n<h3>Usage: /hueapi?devicename=huetest&state=on&brightness=100&r=0&g=0&b=0&colortemp=270&transition=1</h3>\n<h4>Note: this page is always displayed regardless if command is successful or not.</h4>\n</body>\n</html>","x":490,"y":180,"wires":[["bf0118ca.6ffa08"]]},{"id":"d13ff611.844ac8","type":"http in","z":"ecbf4921.26b488","name":"","url":"/hueapi","method":"get","upload":false,"swaggerDoc":"","x":350,"y":120,"wires":[["84c8aed7.2462a","772e44e0.eeb13c"]]},{"id":"bf0118ca.6ffa08","type":"http response","z":"ecbf4921.26b488","name":"","x":610,"y":180,"wires":[]},{"id":"84c8aed7.2462a","type":"function","z":"ecbf4921.26b488","name":"HTTP Control","func":"var state = msg.req.query.state;\nvar brightness = msg.req.query.brightness;\nvar r = msg.req.query.r;\nvar g = msg.req.query.g;\nvar b = msg.req.query.b;\nvar colortemp = msg.req.query.colortemp;\nvar devicename = msg.req.query.devicename;\nvar transition = msg.req.query.transition;\nmsg.payload = {}\n\n\nmsg.payload.state = state;\nmsg.payload.brightness = brightness;\nmsg.payload.transition = transition;\nif (r === '0' && g === '0' && b === '0') {\nmsg.payload.color_temp = colortemp;\n}else{\nmsg.payload.color = {\"r\":r,\"g\":g,\"b\":b};\n}\nmsg.topic = 'zigbee2mqtt/'+devicename+'/set';\n\nreturn msg;\n","outputs":1,"noerr":0,"x":520,"y":120,"wires":[["f7ed5194.3f7f9"]]},{"id":"f7ed5194.3f7f9","type":"mqtt out","z":"ecbf4921.26b488","name":"zigbee2mqtt/in","topic":"","qos":"","retain":"","broker":"cd51966f.aa7e38","x":700,"y":120,"wires":[]},{"id":"cd51966f.aa7e38","type":"mqtt-broker","z":"","name":"MQTT","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
Go to: http://noderedip:1880/hueapi

Domoticz Control function maps IDX numbers to Zigbee2MQTT device names.

So far I've disconnected the Xiaomi Hub, now I can get rid of my Hue bridge. :mrgreen:
Last edited by ben53252642 on Monday 22 October 2018 16:03, edited 1 time in total.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
StasDemydiuk
Posts: 59
Joined: Saturday 14 January 2017 21:37
Target OS: Linux
Domoticz version: Beta
Location: Ukraine
Contact:

Re: Zigbee2MQTT

Post by StasDemydiuk »

I started implementing python plugin for domoticz to add native zigbee2mqtt support
viewtopic.php?f=65&t=24975
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Re: Zigbee2MQTT

Post by quack3d »

Sweet. Think I need to order some new hardware now. Please don't forget Windows support.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Zigbee2MQTT

Post by EddyG »

ben53252642 wrote: Friday 21 September 2018 0:34 EddyG, check this out,

Worked out how to use a variable for the MQTT topic.
Will do in october after my holiday.
Willem16
Posts: 1
Joined: Saturday 22 September 2018 22:39
Target OS: Linux
Domoticz version:
Location: Zuid Holland, The Netherlands
Contact:

Re: Zigbee2MQTT

Post by Willem16 »

Hey guys,

I've just started with home domotica. I would like to use domoticz on a ubuntu machine. I've installed domoticz. I've flashed a cc2531 usb sniffer and would like to use this with domoticz, but from here it gets a bit blurry.

- As I understood I need to install and run CC2531 https://github.com/Koenkk/zigbee2mqtt/w ... the-bridge
- I've installed mqtt as well (https://www.vultr.com/docs/how-to-insta ... untu-16-04)
- And I've installed domoticz-zigbee2mqtt-plugin (https://github.com/stas-demydiuk/domoti ... qtt-plugin)

I think it goes wrong with the domoticz-zigbee2mqtt-plugin.

Is there a step by step guide how to set this up for a noob like me? Or is there someone how could help me with this? I really would appreciate it.

I'm planning to use this setup to combine the Ikea Tradfri with the Xiaomi censors. I've allready have a couple of Ikea tradfri bulbs and the Xiaomi Magic cube.

Thanks!
Willem
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest