Python Plugin: Zigbee2Mqtt Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
StasDemydiuk
Posts: 59
Joined: Saturday 14 January 2017 21:37
Target OS: Linux
Domoticz version: Beta
Location: Ukraine
Contact:

Python Plugin: Zigbee2Mqtt

Post by StasDemydiuk »

zigbee2mqtt project allows you to use your Zigbee devices without the vendors (Xiaomi/TRADFRI/Hue) bridge or gateway.
It bridges events and allows you to control your Zigbee devices via MQTT.

This plugin adds zigbee2mqtt support into domoticz
https://github.com/stas-demydiuk/domoti ... qtt-plugin

Plugin subscribes to mqtt messages from zigbee2mqtt app and creates devices in domoticz once receive any message from them.
For battery powered devices it also handles battery level if it is available in the message

Currently supported device list and instructions for installation you can find in plugin repository.
If you find any issues please report them directly in github. Any contributions are welcome.

02.05.2020 Update:
New version of plugin (v.0.2.0) has been released which among other changes introduces additional page to Domoticz UI to manage the plugin and zigbee2mqtt instance:

Image
Any feedback is highly welcome.
Last edited by StasDemydiuk on Saturday 02 May 2020 12:06, edited 1 time in total.
tezzlicious
Posts: 39
Joined: Saturday 09 April 2016 13:47
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by tezzlicious »

Just had time to dive into this. Looking very nice. Got all necessary parts up and running. Just need support for the Aqara door/window sensor.

Thanks for all the efforts.

Edit: Stanislav added support for the Aqara door/window sensor as we speak.
jake
Posts: 742
Joined: Saturday 30 May 2015 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by jake »

Did you check out this topic already? It is about the same project.
MiloshCZ
Posts: 19
Joined: Monday 23 January 2017 17:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by MiloshCZ »

jake: This thread is about new plugin, that supports Zigbee2MQTT. I think, that plugin is better than NOdeRed implementation.

StasDemydiuk: Nice work, please continue with it.
MarFan
Posts: 18
Joined: Monday 02 September 2013 15:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by MarFan »

I'm trying to get this installed.
I followed your instruction on Github, but see that the important flag "include_device_information" is in the DEV verion of Zigbee2MQTT.

How to get this version ?
MarFan / NL / 3x RasPi / RfXcom / RfLink / S0PCM-5 / P1
StasDemydiuk
Posts: 59
Joined: Saturday 14 January 2017 21:37
Target OS: Linux
Domoticz version: Beta
Location: Ukraine
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by StasDemydiuk »

MarFan wrote: Monday 01 October 2018 12:16 I'm trying to get this installed.
I followed your instruction on Github, but see that the important flag "include_device_information" is in the DEV verion of Zigbee2MQTT.

How to get this version ?
It depends on how are you running zigbee2mqtt:
if you just downloaded it by cloning git repository, then checkout dev branch

Code: Select all

git checkout dev
npm install
if you are using docker container, it has special tag with build from dev branch
MarFan
Posts: 18
Joined: Monday 02 September 2013 15:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by MarFan »

StasDemydiuk wrote: Monday 01 October 2018 15:14 It depends on how are you running zigbee2mqtt:
if you just downloaded it by cloning git repository, then checkout dev branch

Code: Select all

git checkout dev
npm install
if you are using docker container, it has special tag with build from dev branch
Thanks, it's working.

a) what means the log-Message "Device Z2M - Cube does not have saved model" I also see this by my xiaomi double button.
b) is there also a option to send set messages (to contol a IKEA lamp ?)

c) I created sensor_86sw1 (Xiaomi WXKG03LM). How do you want to add this ?
MarFan / NL / 3x RasPi / RfXcom / RfLink / S0PCM-5 / P1
StasDemydiuk
Posts: 59
Joined: Saturday 14 January 2017 21:37
Target OS: Linux
Domoticz version: Beta
Location: Ukraine
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by StasDemydiuk »

what means the log-Message "Device Z2M - Cube does not have saved model"
It means that currently this plugin doesn't support this device.
is there also a option to send set messages (to contol a IKEA lamp ?)
Yes zigbee2mqtt has ability to control devices and this this plugin also supports this ability when applicable

If device is not supported yet, you probably can create issue on github to add support for specific device and attach examples of mqtt messages from device and commands to control it if applicable as unfortunately I don't have all these devices.
MarFan
Posts: 18
Joined: Monday 02 September 2013 15:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by MarFan »

StasDemydiuk wrote: Tuesday 02 October 2018 8:18
what means the log-Message "Device Z2M - Cube does not have saved model"
It means that currently this plugin doesn't support this device.
This is strange, as test I used the Cube and the double switch. Both are created by the plugin and work.
In the code I see the implementation of these Xiaomi devices?
is there also a option to send set messages (to contol a IKEA lamp ?)
Yes zigbee2mqtt has ability to control devices and this this plugin also supports this ability when applicable
Oké, I will create sample of mqtt message for the devices.
If device is not supported yet, you probably can create issue on github to add support for specific device and attach examples of mqtt messages from device and commands to control it if applicable as unfortunately I don't have all these devices.
Oké, clear. I already added the single switch in code, but will create a issue in GitHub.
I created the SW1 with the code of SW2, but did not find the option to create it as a push-button type instead of selection
MarFan / NL / 3x RasPi / RfXcom / RfLink / S0PCM-5 / P1
StasDemydiuk
Posts: 59
Joined: Saturday 14 January 2017 21:37
Target OS: Linux
Domoticz version: Beta
Location: Ukraine
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by StasDemydiuk »

This is strange, as test I used the Cube and the double switch. Both are created by the plugin and work.
In the code I see the implementation of these Xiaomi devices?
Sorry, misunderstood your first message, yes, you're right, cube is supported by plugin.
I wonder if you could follow these steps to find root cause of your issue:
1. delete your cube device created by plugin from domoticz
2. make any action with cube to force plugin to recreate it
3. check if everything is working fine
4. repeat all changes that you've done with cube and try to identify after what change it stops working
StasDemydiuk
Posts: 59
Joined: Saturday 14 January 2017 21:37
Target OS: Linux
Domoticz version: Beta
Location: Ukraine
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by StasDemydiuk »

Code: Select all

I created the SW1 with the code of SW2, but did not find the option to create it as a push-button type instead of selection
Could you please provide example of MQTT message for this device and I'll add support
upwindanderl
Posts: 8
Joined: Wednesday 03 October 2018 21:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by upwindanderl »

@StasDemydiuk
YOU are my hero :)

I installed domoticz only because of your plugin.
I know it's the very first beginning of the plugin, but I think this is my perfect solution


I tried to install today and after the GitHub clone and the configuration.yaml thing I can't see the "type "Zigbee2MQTT"" in my hardware menu
Do you have any idea?


edit:
omg - i see, sometimes reading is helpful

i installed zigbee2mqtt M O N T H S ago and of course with the normal git clone

Code: Select all

sudo git clone https://github.com/Koenkk/zigbee2mqtt.git /opt/zigbee2mqtt
two questions, how can I change to the dev branch?!
Is it only a reinstall or do I have to consider something that it doesn't end in a second install version?
Do i loose all my already linked zigbee devices ??

You see - I'm not used in ubuntu / terminal e.g. at all - but I managed a lot
Maybe you can help out :)
StasDemydiuk
Posts: 59
Joined: Saturday 14 January 2017 21:37
Target OS: Linux
Domoticz version: Beta
Location: Ukraine
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by StasDemydiuk »

@upwindanderl that should help:

Code: Select all

cd /opt/zigbee2mqtt
git fetch
git checkout dev
npm install
upwindanderl
Posts: 8
Joined: Wednesday 03 October 2018 21:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by upwindanderl »

StasDemydiuk wrote: Thursday 04 October 2018 19:30 @upwindanderl that should help:

Code: Select all

cd /opt/zigbee2mqtt
git fetch
git checkout dev
npm install
THANKS !!!! But do you think i don't lose my already connected sensors and actors with this kind of install?!
StasDemydiuk
Posts: 59
Joined: Saturday 14 January 2017 21:37
Target OS: Linux
Domoticz version: Beta
Location: Ukraine
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by StasDemydiuk »

I would say no as they are paired to your controller, not to zigbee2mqtt, so most likely everything will be ok
upwindanderl
Posts: 8
Joined: Wednesday 03 October 2018 21:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by upwindanderl »

puuuuuuuh long way :( :( :/

so i'm already on the dev branch
and i installed npm and after all i don't see any zigbee hardware:
Image

So
I thought it could be a problem with a not updatet zigbee2mqtt
and i tried to update and while the npm install i get following errors

Code: Select all

pi@raspberrypi:/opt/zigbee2mqtt2 $ sudo git checkout dev
M	data/configuration.yaml
Already on 'dev'
Your branch is up-to-date with 'origin/dev'.
pi@raspberrypi:/opt/zigbee2mqtt2 $ sudo systemctl stop zigbee2mqtt
pi@raspberrypi:/opt/zigbee2mqtt2 $ cp -R data data-backup
pi@raspberrypi:/opt/zigbee2mqtt2 $ sudo git checkout HEAD -- npm-shrinkwrap.json
pi@raspberrypi:/opt/zigbee2mqtt2 $ sudo git pull
Already up-to-date.
pi@raspberrypi:/opt/zigbee2mqtt2 $ sudo rm -rf node_modules
pi@raspberrypi:/opt/zigbee2mqtt2 $ sudo npm install
Unhandled rejection Error: Command failed: /usr/bin/git clone --depth=1 -q -b master https://github.com/Koenkk/zigbee-shepherd.git /root/.npm/_cacache/tmp/git-clone-29bcec6d
/root/.npm/_cacache/tmp/git-clone-29bcec6d/.git: Permission denied

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:554:12)

Unhandled rejection Error: Command failed: /usr/bin/git clone --depth=1 -q -b master https://github.com/Koenkk/zcl-packet.git /root/.npm/_cacache/tmp/git-clone-a9db7c08
/root/.npm/_cacache/tmp/git-clone-a9db7c08/.git: Permission denied

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

Unhandled rejection Error: Command failed: /usr/bin/git clone --depth=1 -q -b master https://github.com/Koenkk/cc-znp.git /root/.npm/_cacache/tmp/git-clone-ed91fbf9
/root/.npm/_cacache/tmp/git-clone-ed91fbf9/.git: Permission denied

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:554:12)


> [email protected] install /opt/zigbee2mqtt2/node_modules/serialport
> prebuild-install || node-gyp rebuild

prebuild-install WARN install No prebuilt binaries found (target=8.9.4 runtime=node arch=arm platform=linux)
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/opt/zigbee2mqtt2/node_modules/serialport/build'
gyp ERR! System Linux 4.14.52-v7+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /opt/zigbee2mqtt2/node_modules/serialport
gyp ERR! node -v v8.9.4
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `prebuild-install || node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-10-06T14_10_33_245Z-debug.log
pi@raspberrypi:/opt/zigbee2mqtt2 $ 
Maybe some idea anyone??! :?
StasDemydiuk
Posts: 59
Joined: Saturday 14 January 2017 21:37
Target OS: Linux
Domoticz version: Beta
Location: Ukraine
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by StasDemydiuk »

Looks like some permissions issue, you could try to clone zigbee2mqtt into another folder just for test and copy your data/configuration.yml file to restore your configuration
MarFan
Posts: 18
Joined: Monday 02 September 2013 15:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by MarFan »

StasDemydiuk wrote: Tuesday 02 October 2018 22:38
This is strange, as test I used the Cube and the double switch. Both are created by the plugin and work.
In the code I see the implementation of these Xiaomi devices?
Sorry, misunderstood your first message, yes, you're right, cube is supported by plugin.
I wonder if you could follow these steps to find root cause of your issue:
1. delete your cube device created by plugin from domoticz
2. make any action with cube to force plugin to recreate it
3. check if everything is working fine
4. repeat all changes that you've done with cube and try to identify after what change it stops working
Sorry for the delay, was very busy on other projects. Will do this tomorrow. Also will try to create mqtt samples for other devices.

I deleted the cube (and switch) and recreated them. Now the message is gone (I first updated to the latest version).
Strange thing is, that for both devices Domoticz hangs when making an action for that device (to start the creation of the device) .
After a restart, the device is added and works perfect.
I can reproduce this behavior for these 2 devices. (I only have 1 to test, but I will receive one switch asap)

I do not see this behavior when I add a motion sensor or the door/window sensor ? (can delete and add them without any problems)
Anybody else saw this behavior ?
MarFan / NL / 3x RasPi / RfXcom / RfLink / S0PCM-5 / P1
StasDemydiuk
Posts: 59
Joined: Saturday 14 January 2017 21:37
Target OS: Linux
Domoticz version: Beta
Location: Ukraine
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by StasDemydiuk »

I deleted the cube (and switch) and recreated them. Now the message is gone (I first updated to the latest version).
Strange thing is, that for both devices Domoticz hangs when making an action for that device (to start the creation of the device) .
After a restart, the device is added and works perfect.
I can reproduce this behavior for these 2 devices. (I only have 1 to test, but I will receive one switch asap)
Looks like it is architectural issue as plugin stores additional zigbee related information inside device options which as it turned out is not allowed for devices with own options (Selector Switches) viewtopic.php?f=65&t=25071. So it works only until you change level name or action inside selector switch.

I will try to make something up to avoid this restriction.
upwindanderl
Posts: 8
Joined: Wednesday 03 October 2018 21:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by upwindanderl »

StasDemydiuk wrote: Sunday 07 October 2018 9:57 Looks like some permissions issue, you could try to clone zigbee2mqtt into another folder just for test and copy your data/configuration.yml file to restore your configuration
yeah it was... for every one else Ultramizers 2nd Post was my clue

Anyway i'm not in the goal :(

Now i have the newest zigbee2mqtt and as well the dev branch installed.
I did the flag thing in the yaml
I cloned your plugin and restarted domoticz.


No Zigbee Hardware Device at all ... any debug ideas anyone??
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest