Python Plugin: Zigbee2Mqtt Topic is solved

Python and python framework

Moderator: leecollings

m0rph13
Posts: 18
Joined: Sunday 31 January 2016 1:24
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by m0rph13 »

Any plans on making this work with DeConz hardware?
prelude
Posts: 4
Joined: Tuesday 16 October 2018 20:54
Target OS: Linux
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by prelude »

prelude wrote: Friday 19 October 2018 21:14 Yep, no help from there.
Got it working just replacing "server: 'mqtt://rabbitmq'" -> server: 'mqtt://10.10.10.1' (likely 127.0.0.1 would work also) in configuration.yaml. Funny thing is that pairing works ok but normal "update" messages do not go thru. Ouh yeah, i'm using dockers. And sorry as i do not have now time to check why it work like that.
Hesmink
Posts: 168
Joined: Monday 22 June 2015 10:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by Hesmink »

Hi All,

What is the expected behavior of the aqara water leak sensor?
Mine stays in an 'open' state, even when the alarm is gone already.
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 is the expected behavior of the aqara water leak sensor?
Because it is just simple contact sensor it stays "Open" when there is no water leakage and "Closed" if there is
Hesmink
Posts: 168
Joined: Monday 22 June 2015 10:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: The Netherlands
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by Hesmink »

StasDemydiuk wrote: Sunday 25 November 2018 20:18
What is the expected behavior of the aqara water leak sensor?
Because it is just simple contact sensor it stays "Open" when there is no water leakage and "Closed" if there is
Thanks, works perfectly.
I was confused since the Xiaomi gareways plugin shows them a bit different.
dextm80
Posts: 117
Joined: Tuesday 24 October 2017 18:32
Target OS: Linux
Domoticz version: 4.10159
Contact:

Python Plugin: Zigbee2Mqtt

Post by dextm80 »

Hi, my zigbee2mqtt service works perfectly and send regular updates but my domoticz plugin after a while stops working and seems not to receive data, anyone that have this issue?
Thanks
Image
Domoticz on AsRock j3455-ITX 8gb ram - Aeotec ZWave Usb Stick - RFLink 433Mhz
1x Fibaro Wall Plug
1x Fibaro Motion Sensor
x NeoCoolcam Wall Plug
Netatmo Weather Station - Netatmo Thermostat
Philips Hue Bridge
dextm80
Posts: 117
Joined: Tuesday 24 October 2017 18:32
Target OS: Linux
Domoticz version: 4.10159
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by dextm80 »

anyone can help me to understand where is the problem? my plugin stop receive data after 1/2 days...i've to reboot domoticz.
Service (zigbee2mqtt.service) send data correctly.
Thanks
Domoticz on AsRock j3455-ITX 8gb ram - Aeotec ZWave Usb Stick - RFLink 433Mhz
1x Fibaro Wall Plug
1x Fibaro Motion Sensor
x NeoCoolcam Wall Plug
Netatmo Weather Station - Netatmo Thermostat
Philips Hue Bridge
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by mvzut »

I noticed that (Xiaomi) devices sometimes send updates even when their state (on/off, open/close, temperature, etc.) has not changed. I suspect they do this when e.g. their battery level or signal strength has changed. The zigbee2mqtt bridge copies these updates to mqtt, where the plugin picks them up and updates the corresponding device. This results in multiple "off" updates for e.g. motion sensors when you look at the log.

However, I would personally prefer it if devices are not updated when their actual state has not changed, since I use the value of the "last updated" timestamp in some of my scripts to check when the last movement or door opening took place. Therefore, I made a small modification to the plugin, which makes it check if a device state (svalue) has actually changed before updating it.

Are more people interested in this modification? It would be great if a few people would be willing to test it to check if it doesn't have unforeseen consequences. If it works for everyone, I can make a pull request.

My fork is at:
https://github.com/mvzut/domoticz-zigbee2mqtt-plugin
You could clone the entire plugin structure from there, but the easiest way to test my modification is probably to just download this file:
https://raw.githubusercontent.com/mvzut ... /device.py
And copy it over the existing one in the plugin's subfolder "devices". Restart the plugin once you have copied the new file.

Let me know your opinion and your findings!
Last edited by mvzut on Thursday 20 December 2018 20:38, edited 1 time in total.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by salopette »

I just tried it, replaced file and restarted, but comes with errors!

Code: Select all

2018-12-20 15:12:32.383 Error: (Zigbee2MQTT) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/zigbee2mqtt/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2018-12-20 15:12:32.383 Error: (Zigbee Stick) Module Import failed, exception: 'SyntaxError'
2018-12-20 15:12:32.383 Error: (Zigbee Stick) Import detail: File: /home/pi/domoticz/plugins/zigbee2mqtt/devices/device.py, Line: 7, offset: 1
2018-12-20 15:12:32.383 Error: (Zigbee Stick) Error Line '<!DOCTYPE html>
2018-12-20 15:12:32.383 '
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by mvzut »

salopette wrote:I just tried it, replaced file and restarted, but comes with errors!

Code: Select all

2018-12-20 15:12:32.383 Error: (Zigbee2MQTT) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/zigbee2mqtt/:/usr/lib/python35.zip:/usr/lib/python3.5:/usr/lib/python3.5/plat-arm-linux-gnueabihf:/usr/lib/python3.5/lib-dynload'.
2018-12-20 15:12:32.383 Error: (Zigbee Stick) Module Import failed, exception: 'SyntaxError'
2018-12-20 15:12:32.383 Error: (Zigbee Stick) Import detail: File: /home/pi/domoticz/plugins/zigbee2mqtt/devices/device.py, Line: 7, offset: 1
2018-12-20 15:12:32.383 Error: (Zigbee Stick) Error Line '<!DOCTYPE html>
2018-12-20 15:12:32.383 '
That is strange, the error seems to originate from line 7, which I did not change. I only included one line of code at line 101. Are you sure you ONLY changed this one file with my version? Seems it cannot import a certain module.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by salopette »

yes for sure, I only device.py swapped those.
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by mvzut »

salopette wrote: Thursday 20 December 2018 18:18 yes for sure, I only device.py swapped those.
Looking at your log output, I suspect you did not download the file correctly, if you use wget you should use this direct link to the device.py file:

Code: Select all

cd ~/domoticz/plugins/zigbee2mqtt/devices
wget https://raw.githubusercontent.com/mvzut/domoticz-zigbee2mqtt-plugin/master/devices/device.py
The link I posted earlier was a link to the Github page for this file, not a download link for the file itself (I updated the link in my previous post to avoid confusion).
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
salopette
Posts: 187
Joined: Tuesday 07 March 2017 21:03
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Germany
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by salopette »

thanks, was my mistake!
Have now replaced again, will watch it!
EscApe
Posts: 528
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by EscApe »

@mvzut
However, I would personally prefer it if devices are not updated when their actual state has not changed, since I use the value of the "last updated" timestamp in some of my scripts to check when the last movement or door opening took place. Therefore, I made a small modification to the plugin, which makes it check if a device state (svalue) has actually changed before updating it.
Hi,
I have the same problem, however there are exceptions. Wall switches and remote controls are basically ‘stateless’ (E.g. they don’t know you turned the light off from another switch or voice command). So even if the previous state for the remote was ‘on’ I would still want it to relay another ‘on’ command to turn the lights back on.
It might be better to modify the specific device(type)files instead of the main device.py.
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by mvzut »

EscApe wrote: Saturday 22 December 2018 11:06Wall switches and remote controls are basically ‘stateless’ (E.g. they don’t know you turned the light off from another switch or voice command). So even if the previous state for the remote was ‘on’ I would still want it to relay another ‘on’ command to turn the lights back on.
It might be better to modify the specific device(type)files instead of the main device.py.
Yes, you're right. I have tried to find better ways to avoid multiple updates with the same state, with the intention to exclude buttons (and maybe other devices?) from this check, but haven't succeeded yet. Anyone with better Python skills willing to help, or perhaps the plugin author?
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Python Plugin: Zigbee2Mqtt

Post by mvzut »

mvzut wrote: Sunday 30 December 2018 0:03 Yes, you're right. I have tried to find better ways to avoid multiple updates with the same state, with the intention to exclude buttons (and maybe other devices?) from this check, but haven't succeeded yet. Anyone with better Python skills willing to help, or perhaps the plugin author?
In the meantime, I have found a better way to avoid updates of only door/motion switches when their state has not changed. It involves a few small modifications to the /devices/device.py file, see: https://github.com/mvzut/domoticz-zigbe ... /device.py
Please check it out. I have also created a pull request in Github, because I hope this can become the standard way the plugin handles device updates from door/motion sensors.

Update
My modification had already been incorporated in the main code, so you can simply check out out with a new git pull
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
mvzut
Posts: 443
Joined: Thursday 12 November 2015 10:55
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: The Netherlands
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by mvzut »

I have a Xiaomi Vibration sensor, which I mounted to my cat door. Unfortunately, the Zigbee2Mqtt Python plugin just records states like "Tilt" or "Vibration", and doesn't create separate devices for the tilt angles. Therefore, I could detect if my cat was using the door, but not if it was going in or out.

To solve this, I made a small modification to /adapters/lumi/sensor_vibration.py, it now looks like this:

Code: Select all

from adapters.adapter_with_battery import AdapterWithBattery
from devices.switch.selector_switch import SelectorSwitch
from devices.custom_sensor import CustomSensor


class SensorVibration(AdapterWithBattery):
    def __init__(self, devices):
        super().__init__(devices)

        self.switch = SelectorSwitch(devices, 'action', 'action')
        self.switch.add_level('Off', None)
        self.switch.add_level('Vibration', 'vibration')
        self.switch.add_level('Drop', 'drop')
        self.switch.add_level('Tilt', 'tilt')
        self.switch.set_selector_style(SelectorSwitch.SELECTOR_TYPE_MENU)
        self.devices.append(self.switch)

        self.devices.append(CustomSensor(devices, 'angle', 'angle_z', ' (Rotation Angle Z)'))


    def handleCommand(self, alias, device, device_data, command, level, color):
        self.switch.handle_command(device_data, command, level, color)
The plugin now creates an additional (custom) sensor with the tilt angle, in this case only for the Z angle since this is the angle around which my cat door is tilting. I can now get notifications (using e.g. Lua scripts) about the cat going in or out!

Of course you can adapt this to your own needs. If many people feel that (all?) sensor angles should be shown in custom sensors by default, I could make a pull request for that.
Raspberry Pi 4 - RFXtrx433 - CC2531 Zigbee - Opentherm Gateway - P1 smart meter - Netatmo - Philips Hue - ELV Max! - ESP8266 DIY water meter - 6 x Sonos - 4 x IP cameras - Wall mounted tablet + Dashticz - Google Home integration - MANY switches/sensors
gerbenvanasselt
Posts: 74
Joined: Friday 07 September 2018 14:46
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta 4.1
Location: Netherlands
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by gerbenvanasselt »

Hi guys, I have problem with the plugin version 0.0.15. I'm running domo beta v4.103.
Every 5seconds the domo log gives an update.


019-01-07 20:31:27.328 (zigbee2mqtt) Zigbee2mqtt bridge is online

2019-01-07 20:31:27.329 (zigbee2mqtt) Joining new devices is enabled on the zigbee bridge

2019-01-07 20:31:27.396 (zigbee2mqtt) Received available devices list from bridge


Can this be stopped? Or set less frequent?

Thanks

Verstuurd vanaf mijn ONEPLUS A6003 met Tapatalk

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 »

gerbenvanasselt wrote: Monday 07 January 2019 20:35 Hi guys, I have problem with the plugin version 0.0.15. I'm running domo beta v4.103.
Every 5seconds the domo log gives an update.


019-01-07 20:31:27.328 (zigbee2mqtt) Zigbee2mqtt bridge is online

2019-01-07 20:31:27.329 (zigbee2mqtt) Joining new devices is enabled on the zigbee bridge

2019-01-07 20:31:27.396 (zigbee2mqtt) Received available devices list from bridge


Can this be stopped? Or set less frequent?

Thanks

Verstuurd vanaf mijn ONEPLUS A6003 met Tapatalk
You can try to do one of:
  • update plugin settings
  • remove and then add plugin on Hardware page
Most likely it happened because since you've installed plugin some new settings were added to its config and unfortunately Domoticz behave weirdly with such settings: it doesn't set values to default ones, it just skips these new settings.
sach
Posts: 111
Joined: Wednesday 12 October 2016 14:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Zigbee2Mqtt

Post by sach »

Hi Guys,

I have a Hive Active Plug which I have got working in zigbee2mqtt.
How can I get this supported by the plugin?

Sach
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest