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 »

Zigbee2MQTT is a very active project and the Wiki explains how users can add support for new devices.

It has MASSIVE device support and with Home Assistant having added support for it, it's looking like it might become the Zigbee equivalent of OpenZWave.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
quack3d
Posts: 86
Joined: Sunday 26 March 2017 17:03
Target OS: -
Domoticz version:
Contact:

Re: Zigbee2MQTT

Post by quack3d »

Looks much more complicated than ZiGate though. Can it even be run in Windows?
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Zigbee2MQTT

Post by EddyG »

Indeed more complicated but also more flexible.
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Any idea how to update the battery status of a device without setting it to On or Off or must I set the On / Off state at the same time?
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 don't think so. But what's the logic?
If you use a switch once a day the battery status is updated, that should be enough.
Lifetime of some Xiaomi devices extends to 3 years. So 1% degrade in aprox. 10 days. (if it was linear)
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Yea i know the Xiaomi devices have pretty good battery lives.

The smoke detector for instance sends after I push the test button:
smoke, voltage, battery

After some time it starts only sending
voltage, battery

I've worked around it in Node-Red by sending the off command to Domoticz along with battery when it only receives voltage and battery status since knowing the battery state of a smoke detector = critical.

Other devices though like the Xiaomi button often also send just the battery and voltage.

I guess it's coding perfection than anything else, I'll publish the flow for the smoke detector once I'm happy it's working correctly.
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 thanks for putting together the flow for the Xiaomi Temp + Hum + Baro sensor (saved me a lot of time!)

I've modified it slightly for a sensor that I just installed (also Xiaomi) but it's for Temp + Hum + Baro in a single sensor.

Also corrected a error RE the battery status, the word battery needs to start with a capital B

Code: Select all

[{"id":"ccd928ae.df6e08","type":"mqtt in","z":"f962b96d.7044c8","name":"zigbee2mqtt/out","topic":"zigbee2mqtt/bedroomwindowtempsensor","qos":"2","broker":"6e165f21.f7645","x":340,"y":340,"wires":[["30c7887d.0db668"]]},{"id":"30c7887d.0db668","type":"json","z":"f962b96d.7044c8","name":"","property":"payload","action":"","pretty":false,"x":490,"y":340,"wires":[["903fbd0c.967e8"]]},{"id":"37f9ac4c.00d154","type":"mqtt out","z":"f962b96d.7044c8","name":"","topic":"domoticz/in","qos":"","retain":"","broker":"cd51966f.aa7e38","x":790,"y":340,"wires":[]},{"id":"903fbd0c.967e8","type":"function","z":"f962b96d.7044c8","name":"Format Data","func":"var temp = msg.payload.temperature;\nvar humi = msg.payload.humidity;\nvar pres = msg.payload.pressure;\nvar batt = msg.payload.battery;\nvar rssi = msg.payload.linkquality;\n\nmsg.payload = {}\n\n// Humidity Status\nif (humi < 31) {\n    humistat = \"2\";\n} else if (humi > 69) {\n    humistat = \"3\";\n} else if (humi > 34 && humi < 66 && temp > 21 && temp < 27) {\n    humistat = \"1\";\n} else {\n    humistat = \"0\";\n}\n\n// Pressure Status\nif (pres < 966) {\n    forecast = \"4\";\n} else if (pres < 993) {\n    forecast = \"3\";\n} else if (pres < 1007) {\n    forecast = \"2\";\n} else if (pres < 1013) {\n    forecast = \"3\";\n} else if (pres < 1033) {\n    forecast = \"0\";\n} else {\n    forecast = \"1\";\n}\n\nmsg.payload.idx =  1221\nmsg.payload.nvalue = 0\nmsg.payload.svalue = temp.toString()+\";\"+humi.toString()+\";\"+humistat+\";\"+pres.toString()+\";\"+forecast;\nif (typeof batt !== 'undefined' && batt !== null){\nmsg.payload.Battery = Math.round(batt);\n}\nif (typeof rssi !== 'undefined' && rssi !== null){\nrssi = Math.round(rssi / 12);\nif (rssi > 12) {\n    rssi = 12;\n}\nmsg.payload.RSSI = rssi;\n}\nreturn msg;","outputs":1,"noerr":0,"x":630,"y":340,"wires":[["37f9ac4c.00d154"]]},{"id":"6e165f21.f7645","type":"mqtt-broker","z":"","name":"Zigbee","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"domoticz/bridge/state","birthQos":"0","birthPayload":"online","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"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":""}]
temphumbaro3421423.JPG
temphumbaro3421423.JPG (42.23 KiB) Viewed 12035 times

Also note for those searching since I did not find a posted solution:

Above is how to input Temperature Humidity and Barometer (Temp Hum Baro) into Domoticz via MQTT (working).
Last edited by ben53252642 on Tuesday 21 August 2018 0:11, edited 2 times in total.
Unless otherwise stated, all my code is released under GPL 3 license: https://www.gnu.org/licenses/gpl-3.0.en.html
Dlanor
Posts: 67
Joined: Sunday 22 March 2015 16:18
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Zigbee2MQTT

Post by Dlanor »

Got my CC2531 & CC Debugger, programmed the CC2531, installed the bridge, connect to the domoticz MQTT and it runs but now what to do?! :?
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 »

Install Node-Red so you can import some of the flows in this thread, have you got any Xiaomi Zigbee devices?

viewtopic.php?f=68&t=23607&start=20#p188171

I'm working on a flow for Philips Hue lightstrips atm.
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 »

ben53252642 wrote: Sunday 19 August 2018 19:23 Also corrected a error RE the battery status, the word battery needs to start with a capital B
Yes, I also found out about the capital B.

What you also can do is: replace all the 'delete msg.payload.xxx' with one single 'msg.payload = {};'

I am also now on version: zigbee2mqtt version 0.1.3 and that version also has linkquality, which could be used as RSSI which ranges from 0 to 12.

B.t.w. that works too...
Currently I use the code, mind the capitals again: RSSI

Code: Select all

var rssi = msg.payload.linkquality;
rssi = Math.round(rssi / 12);
if (rssi > 12) {
    rssi = 12;
}
msg.payload.RSSI = rssi;
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

EddyG thanks for the tips, I'll have to upgrade to get the RSSI support.

Btw new Xiaomi sensor was just released (I've ordered a couple) "Xiaomi Zigbee (vibration, tilt, fall) sensor Model: DJT11LM"

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
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Seems to be a bug with the RSSI, if I send:

msg.payload.RSSI = 12;

Domoticz device field is blank. Numbers 11 and under seem to work fine, EddyG are you seeing the same?
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 »

Yes, I did not test it properly, but took the wiki API documentation for true, which states default=12, but that gives a dash (-) in domoticz.
So I adapted the code to max 11.
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Zigbee2MQTT

Post by EddyG »

Now I am looking for a nice transparent enclosure for the Zigbee CC2531 USB stick.
Anyone any suggestions?
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Me too, I saw some on Aliexpress had some but they didn't have the program pin connectors as easy to access.

If you find one, let me know. I bought 3x units so if one fails I can replace it.

Still I prefer it to be in a protected case...

Also I started a git issue for a backup / restore function, if they had that I'd feel ok with just having the spares.

https://github.com/Koenkk/zigbee2mqtt/issues/266
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 »

ben53252642 wrote: Monday 20 August 2018 21:00 EddyG thanks for the tips, I'll have to upgrade to get the RSSI support.

Btw new Xiaomi sensor was just released (I've ordered a couple) "Xiaomi Zigbee (vibration, tilt, fall) sensor Model: DJT11LM"

https://github.com/Koenkk/zigbee2mqtt/issues/295
Is this device already supported?
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

Not yet, mine should be delivered either tomorrow or Monday, should be supported by next Friday.

I ordered a couple more as well (4 total), I'm very excited about these sensors, lots of new unique use cases.
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 get this kind of data back, but do not know what it means and how to implement it in 'fromZigbee.js'

Code: Select all

2018-8-30 13:46:32 - debug: Recieved zigbee message with data {"cid":"closuresDoorLock","data":{"85":2,"1283":85}}
2018-8-30 13:46:32 - warn: No converter available for 'DJT11LM' with cid 'closuresDoorLock', type 'attReport' and data '{"cid":"closuresDoorLock","data":{"85":2,"1283":85}}'
2018-8-30 13:46:32 - warn: Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices.
2018-8-30 13:46:32 - debug: Recieved zigbee message with data {"cid":"closuresDoorLock","data":{"85":2,"1283":85}}
2018-8-30 13:46:32 - warn: No converter available for 'DJT11LM' with cid 'closuresDoorLock', type 'devChange' and data '{"cid":"closuresDoorLock","data":{"85":2,"1283":85}}'
2018-8-30 13:46:32 - warn: Please see: https://github.com/Koenkk/zigbee2mqtt/wiki/How-to-support-new-devices.
2018-8-30 13:46:33 - debug: Recieved zigbee message with data {"cid":"closuresDoorLock","data":{"1288":[107,4227465292]}}
2018-8-30 13:46:33 - warn: No converter available for 'DJT11LM' with cid 'closuresDoorLock', type 'attReport' and data '{"cid":"closuresDoorLock","data":{"1288":[107,4227465292]}}'

Code: Select all

2018-8-30 13:52:25 - debug: Recieved zigbee message with data {"cid":"genBasic","data":{"65282":[{"elmType":16,"elmVal":1},{"elmType":33,"elmVal":3025},{"elmType":33,"elmVal":5032},{"elmType":36,"elmVal":[0,35]},{"elmType":33,"elmVal":13},{"elmType":32,"elmVal":84}]}}
The word 'closuresDoorLock' is present in a few files, but does not give a qlue how to implement.
ben53252642
Posts: 543
Joined: Saturday 02 July 2016 5:17
Target OS: Linux
Domoticz version: Beta
Contact:

Re: Zigbee2MQTT

Post by ben53252642 »

I'd post in the Git thread, don't have mine yet :(

https://github.com/Koenkk/zigbee2mqtt/w ... ew-devices

https://github.com/Koenkk/zigbee2mqtt/issues/295

What's going to be interesting with this sensor is the sensitivity setting, it's either one of two:

1) Set via Zigbee on the unit

2) Set as a parameter on the Xiaomi hub

I'm guessing its number 1 since it could result in reduced battery consumption (makes sense).

https://www.gearbest.com/robot-vacuum-a ... 85513.html

Good luck! Maybe you will beat me to it. ;)
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 »

Cheapest on Ali € 10,21
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest