Page 1 of 1

Vibration sensor dzvents (zigbee2mqtt)

Posted: Sunday 03 May 2020 17:55
by kitopopo
Dear friends,

I am trying to make a dzevents script with a xiaomi vibration sensor with zigbee2mqtt. In the domoticz i can see te following info:

'strenght' : 77 , 'action' : vibration ,,angle_x_absolute' :165 and more values,

How i can use this values in a dzvents script? I test:

If dz.devices('mysensor').state == 'vibration' then
If dz.devices('mysensor').value == 'vibration' then
If dz.devices('mysensor').level == 'vibration' then
If dz.devices('mysensor').actice == 'vibration' then

Any commands works with my sensor. I need also use 'strenght' value for close my awinds but i don't know the command. I have test:

If dz.devices('mysensor').strenght >= 150 then

I have readed the dzvents wiki but no appears any info about this sensor. My domoticz and the zigbee2mqtt only detects 1 device ( vibration sensor ).
Would it be needed that domoticz detect more devices strenght, vibration,tilt.... ) i don't know more. Any idea?

If is not possible currently use a vibration or strenght value, Could you please add this feature for zigbee2mqtt in the following updates?

Thanks in advanced

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Sunday 03 May 2020 18:34
by waaren
kitopopo wrote: Sunday 03 May 2020 17:55 I am trying to make a dzevents script with a xiaomi vibration sensor with zigbee2mqtt. In the domoticz i can see te following info:
How i can use this values in a dzvents script? I test:
If is not possible currently use a vibration or strenght value, Could you please add this feature for zigbee2mqtt in the following updates?
Can you please add

Code: Select all

domoticz.devices('vibration sensor name').dump() 
somewhere in your script and reply with the complete output of that command?
That might help in identifying how a dzVents script could work for this type of device.

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 0:36
by kitopopo
Dear friend,

The problem is related with my old post about vibration sensor , viewtopic.php?f=6&t=31134

I have managed to configure the a notification for the vibration sensor using domoticz.devices('myvibrationsensor'). state == 'Vibration' , the notification works correctly, but as I commented in my previous post to which no one responded, when a vibration occurs physical vibration sensor the notification does not arrive, it is only shown in the general log of domoticz.

2020-05-03 23:48:44.171 (zigbe2mqtt) MQTT message: zigbee2mqtt/0x00158d0002a51c0a {'battery': 100, 'voltage': 3025, 'linkquality': 115, 'angle': 5, 'angle_x': 9, 'angle_y': -68, 'angle_z': 20, 'angle_x_absolute': 81, 'angle_y_absolute': 158, 'strength': 24}

The vibration is not registered in the individual registry of domoticz. I only get the notification to work by pressing the vibration sensor on domoticz by selecting vibration, this notification if it is marked as admin within the individual domoticz record:

2020-05-03 23:45:06 Vibration Admin
2020-05-03 23:45:02 Off Admin
2020-05-03 23:44:18 Vibration Admin
2020-05-03 23:44:03 Off Admin

A physical vibration not is recorded in the individual log, i have 20 devices zigbe2mqtt and this device only have individual log problem, The log works correctly in other sensors, I have tried everything, empty cache and cockies of browser, unpair and re-pair ... etc but the problem persist.

as you commented in your previous answer this is the result of --> domoticz.devices('vibration sensor name').dump() . with this information i can see thet this sensor is a selector switch, i can not see the strenght value.
Spoiler: show

Code: Select all

2020-05-03 23:50:55.525 Status: dzVents: > levelActions:
2020-05-03 23:50:55.525 Status: dzVents: > updateWetness()
2020-05-03 23:50:55.525 Status: dzVents: > usedByCamera: false
2020-05-03 23:50:55.525 Status: dzVents: > kodiSetVolume()
2020-05-03 23:50:55.525 Status: dzVents: > baseType: device
2020-05-03 23:50:55.525 Status: dzVents: > switchType: Selector
2020-05-03 23:50:55.525 Status: dzVents: > deviceSubType: Selector Switch
2020-05-03 23:50:55.525 Status: dzVents: > isScene: false
2020-05-03 23:50:55.525 Status: dzVents: > incrementCounter()
2020-05-03 23:50:55.525 Status: dzVents: > lastLevel: 10
2020-05-03 23:50:55.525 Status: dzVents: > setHue()
2020-05-03 23:50:55.525 Status: dzVents: > protected: false
2020-05-03 23:50:55.525 Status: dzVents: > disarm()
2020-05-03 23:50:55.525 Status: dzVents: > dimTo()
2020-05-03 23:50:55.525 Status: dzVents: > open()
2020-05-03 23:50:55.525 Status: dzVents: > protectionOn()
2020-05-03 23:50:55.525 Status: dzVents: > switchOn()
2020-05-03 23:50:55.525 Status: dzVents: > toggleSwitch()
2020-05-03 23:50:55.525 Status: dzVents: > quietOff()
2020-05-03 23:50:55.525 Status: dzVents: > switchTypeValue: 18
2020-05-03 23:50:55.525 Status: dzVents: > state: Vibration
2020-05-03 23:50:55.525 Status: dzVents: > kodiExecuteAddOn()
2020-05-03 23:50:55.525 Status: dzVents: > kodiPlayFavorites()
2020-05-03 23:50:55.525 Status: dzVents: > active: false
2020-05-03 23:50:55.525 Status: dzVents: > deviceType: Light/Switch
2020-05-03 23:50:55.525 Status: dzVents: > setHotWater()
2020-05-03 23:50:55.525 Status: dzVents: > updateAlertSensor()
2020-05-03 23:50:55.525 Status: dzVents: > updateTemperature()
2020-05-03 23:50:55.525 Status: dzVents: > updateElectricity()
2020-05-03 23:50:55.525 Status: dzVents: > kodiStop()
2020-05-03 23:50:55.525 Status: dzVents: > updateWaterflow()
2020-05-03 23:50:55.525 Status: dzVents: > cancelQueuedCommands()
2020-05-03 23:50:55.525 Status: dzVents: > levelNames:
2020-05-03 23:50:55.525 Status: dzVents: > 1: Off
2020-05-03 23:50:55.525 Status: dzVents: > 2: Vibration
2020-05-03 23:50:55.525 Status: dzVents: > 3: Drop
2020-05-03 23:50:55.525 Status: dzVents: > 4: Tilt
2020-05-03 23:50:55.525 Status: dzVents: > updateText()
2020-05-03 23:50:55.525 Status: dzVents: > hardwareName: zigbe2mqtt
2020-05-03 23:50:55.525 Status: dzVents: > pause()
2020-05-03 23:50:55.525 Status: dzVents: > isVariable: false
2020-05-03 23:50:55.525 Status: dzVents: > levelOffHidden: false
2020-05-03 23:50:55.525 Status: dzVents: > updateGas()
2020-05-03 23:50:55.525 Status: dzVents: > onkyoEISCPCommand()
2020-05-03 23:50:55.525 Status: dzVents: > updateVoltage()
2020-05-03 23:50:55.525 Status: dzVents: > hardwareId: 22
2020-05-03 23:50:55.525 Status: dzVents: > timedOut: false
2020-05-03 23:50:55.525 Status: dzVents: > _data:
2020-05-03 23:50:55.525 Status: dzVents: > id: xxx
2020-05-03 23:50:55.525 Status: dzVents: > baseType: device
2020-05-03 23:50:55.526 Status: dzVents: > switchTypeValue: 18
2020-05-03 23:50:55.526 Status: dzVents: > signalLevel: 12
2020-05-03 23:50:55.526 Status: dzVents: > rawData:
2020-05-03 23:50:55.526 Status: dzVents: > 1: 10
2020-05-03 23:50:55.526 Status: dzVents: > changed: false
2020-05-03 23:50:55.526 Status: dzVents: > lastUpdate: 2020-05-03 23:45:06
2020-05-03 23:50:55.526 Status: dzVents: > subType: Selector Switch
2020-05-03 23:50:55.526 Status: dzVents: > timedOut: false
2020-05-03 23:50:55.526 Status: dzVents: > protected: false
2020-05-03 23:50:55.526 Status: dzVents: > deviceID: 0x0xxxxxx..._action
2020-05-03 23:50:55.526 Status: dzVents: > description:
2020-05-03 23:50:55.526 Status: dzVents: > batteryLevel: 255
2020-05-03 23:50:55.526 Status: dzVents: > name: sensor vibra
2020-05-03 23:50:55.526 Status: dzVents: > data:
2020-05-03 23:50:55.526 Status: dzVents: > hardwareType: Zigbee2MQTT
2020-05-03 23:50:55.526 Status: dzVents: > hardwareID: 22
2020-05-03 23:50:55.526 Status: dzVents: > levelActions:
2020-05-03 23:50:55.526 Status: dzVents: > protected: false
2020-05-03 23:50:55.526 Status: dzVents: > levelVal: 10
2020-05-03 23:50:55.526 Status: dzVents: > _state: Vibration
2020-05-03 23:50:55.526 Status: dzVents: > hardwareName: zigbe2mqtt
2020-05-03 23:50:55.526 Status: dzVents: > _nValue: 1
2020-05-03 23:50:55.526 Status: dzVents: > hardwareTypeValue: 94
2020-05-03 23:50:55.526 Status: dzVents: > unit: 64
2020-05-03 23:50:55.526 Status: dzVents: > maxDimLevel: 100
2020-05-03 23:50:55.526 Status: dzVents: > levelOffHidden: false
2020-05-03 23:50:55.526 Status: dzVents: > icon: Light
2020-05-03 23:50:55.526 Status: dzVents: > levelNames: Off|Vibration|Drop|Tilt
2020-05-03 23:50:55.526 Status: dzVents: > usedByCamera: false
2020-05-03 23:50:55.526 Status: dzVents: > switchType: Selector
2020-05-03 23:50:55.526 Status: dzVents: > lastLevel: 10
2020-05-03 23:50:55.526 Status: dzVents: > deviceType: Light/Switch
2020-05-03 23:50:55.526 Status: dzVents: > updateSoundLevel()
2020-05-03 23:50:55.526 Status: dzVents: > armAway()
2020-05-03 23:50:55.526 Status: dzVents: > updatePercentage()
2020-05-03 23:50:55.526 Status: dzVents: > updateWeight()
2020-05-03 23:50:55.526 Status: dzVents: > updateBarometer()
2020-05-03 23:50:55.526 Status: dzVents: > setColorBrightness()
2020-05-03 23:50:55.526 Status: dzVents: > dump()
2020-05-03 23:50:55.526 Status: dzVents: > updateCustomSensor()
2020-05-03 23:50:55.526 Status: dzVents: > setIcon()
2020-05-03 23:50:55.526 Status: dzVents: > _adapters:
2020-05-03 23:50:55.526 Status: dzVents: > 1: Switch device adapter
2020-05-03 23:50:55.526 Status: dzVents: > maxDimLevel: 100
2020-05-03 23:50:55.526 Status: dzVents: > updateHumidity()
2020-05-03 23:50:55.526 Status: dzVents: > isSecurity: false
2020-05-03 23:50:55.526 Status: dzVents: Info: ------ Finished test domoticz
I was talking to the developer of zigbee2mqtt and thanks to @koenkk I got him to help me and included the strenght information in the sensor information to be able to close my awnings when the wind blows to the desired value. I still don't know if this could be done already I don't see this information in the log and exist problems with the individual record.

I've been asking to include the value of strenght for almost 1 year (https://github.com/domoticz/domoticz/issues/3300). @gizmocuz answered to the request.

I'm not sure if this post should move to the bugs and problems section.

Thanks in advance and for your work, receive a coridal greeting

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 8:38
by waaren
kitopopo wrote: Monday 04 May 2020 0:36 The problem is related with my old post about vibration sensor , viewtopic.php?f=6&t=31134
Quite a long story already but from what I understand the situation is that when using the zigate plugin it all works and when using zigbee2mqtt or the native Xiaomi hardware module you do not see the strength of the vibration.
Not quite clear for me from your post if the zigbee2mqtt does switch the selector to "Vibrate" and if so why the notification is not send.

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 12:42
by kitopopo
Hello, thank you very much for your response and for your attention, summary:

I don't use zigate. A colleague commented that with zigate if you could see the strenght value, as he could ask @koenkk to include the strenght value in zigbee2mqtt, that was at the beginning. I summarize the problem in 5 steps:

- The main log from Domoticz detects correctly the vibration and the strenght value ( physical vibration detected from the sensor)

domoticz main.log

Code: Select all

2020-05-03 23:48:44.171 (zigbe2mqtt) MQTT message: zigbee2mqtt/0x00158d0002a51c0a {'battery': 100, 'voltage': 3025, 'linkquality': 115, 'angle': 5, 'angle_x': 9, 'angle_y': -68, 'angle_z': 20, 'angle_x_absolute': 81, 'angle_y_absolute': 158, 'strength': 24}
-the individual vibration sensor log does not record the physical vibrations caused by the vibration sensor, it only records the vibrations pressing the vibration selector of my switch in my sensor in domoticz (Vibration admin) --> red power button icon in domoticz vibration switch

vibration sensor.log

Code: Select all

2020-05-03 23:45:06 Vibration Admin
2020-05-03 23:45:02 Off Admin
2020-05-03 23:44:18 Vibration Admin
2020-05-03 23:44:03 Off Admin
-due to these vibrations are only detected in the domoticz main log but not in the individual log of my sensor, my script not trigger with a physical vibration from the sensor. My script only triggers with a manually triggered vibration on the domoticz switch.

If dz.devices('mysensor').status == 'Vibration' then --> send a notification --> works only with a forced vibration (manual vibration from domoticz switch)

- If my script does not trigger with a simple physical vibration coming from the sensor, due to the individual vibration sensor log does not detect any value vibrations, i think that my script will not trigger with the strenght value either, anyway I don't know how to use the strenght value in my script, that's why I wrote you the dump () values ​​in my previous answer:

If dz.devices('mysensor').strenght >= 150 --> then close my awings ( I don't know what would be the correct command that would work with my sensor, but if this command were the correct command it would never work because the log of my vibration sensor does not record data, they only appear in the main log of domoticz.

I hope it is understood, it is quite difficult to explain, thanks for your attention again, kind regards

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 12:51
by waaren
kitopopo wrote: Monday 04 May 2020 12:42 I hope it is understood, it is quite difficult to explain, thanks for your attention again, kind regards
Sorry but that does not answer my question: "Does zigbee2mqtt switch the selector to "Vibrate" ?

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 13:06
by kitopopo
Sorry, I hadn't read your question.

The answer is today yes but not yesterday night.
I put the vibration switch off, I move the awning and the switch goes into vibration mode. Now if you have registered in the individual log and the notification has arrived.

It seems that when the first vibration occurs the switch kept vibrating and then it no longer detects any more vibrations, should it go back to off so that it continues to detect more vibrations? maybe I can do this using scripts
Now I just need to know how I can use the strenght value in my script. what could be the correct command of the strenght value?

If dz.devices('mysensor').strenght >= 150
something similar to this?

Thank you for your attention

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 13:27
by waaren
kitopopo wrote: Monday 04 May 2020 13:06 It seems that when the first vibration occurs the switch kept vibrating and then it no longer detects any more vibrations.
The notification will only be send when the selector device switches to "Vibrate".
So yes a script that will set the selector back to Off is necessary. You might as well do the notification task in the script as well.
Now I just need to know how I can use the strength value in my script. what could be the correct command of the strength value?
From what I see in the dump() and by what you describe the strength value is not send to any domoticz device or variable. dzVents can only do something with a strength value when it knows where to find it.

What component (hardware / software) sets the selector switch to "Vibrate"?

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 13:47
by kitopopo
Again, thank you very much,

I have already made a script and the vibration switch now correctly goes to Off. Perfect.

The vibration sensor vibrates and zigbee2mqtt detects this vibration in the log:

Code: Select all

may 04 13:30:02 raspberrypi npm[426]: zigbee2mqtt:info  2020-05-04 13:30:02: MQTT publish: topic 'zigbee2mqtt/0x00158xxxxxxxxxxxx', payload '{"battery":100,"voltage":3025,"linkquality":115,"angle":5,"angle_x":9,"angle_y":-68,"angle_z":20,"angle_x_absolute":81,"angle_y_absolute":158,"strength":20}'
The usb zigbe2mqtt (cc2531) itself sends the information to domoticz. Domoticz generates 3 devices:

Code: Select all

4xx	zigbe2mqtt	0x00158d000xxxxx_signal	54	zigbe2mqtt - 0x00158d000xxxxx (Link Quality)	General	Custom Sensor	115
4xx	zigbe2mqtt	0x00158d000xxxxx_cell	60	zigbe2mqtt - 0x00158d000xxxxx (Battery Voltage)	General	Voltage	3.025 V
4xx	zigbe2mqtt	0x00158d000xxxxx_action	64	sensor vibra	Light/Switch	Selector Switch	Off
Zigbee2mqtt cc2531 detects the vibration and send this info to domoticz and the vibration switch set to vibration mode.

A Mr@koenkk (zigbee2mqtt developer) to which I am very grateful it took work to implement this value, since it was hidden within the information that it sent, and it was under another name. in the end he managed to replace the error in the name

Maybe we need add in domoticz a fourth device with the streengt value name?

It should not be difficult if the value strenght appears in the main log the domoticz

Code: Select all

2020-05-04 13:49:39.335 (zigbe2mqtt) MQTT message: zigbee2mqtt/0x00158d0002a51c0a {'battery': 100, 'voltage': 3025, 'linkquality': 113, 'angle': 5, 'angle_x': 9, 'angle_y': -68, 'angle_z': 20, 'angle_x_absolute': 81, 'angle_y_absolute': 158, 'strength': 9, 'action': 'vibration'}
It would be very interesting to use it to close the awnings since this value goes from 0 to 999 and measures the wind force very well at a very affordable price. I and many other domoticz users of the telegram group would be very grateful for this implementation.

Thanks in advanced.

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 13:59
by waaren
kitopopo wrote: Monday 04 May 2020 13:47 The usb zigbe2mqtt (cc2531) itself sends the information to domoticz. Domoticz generates 3 devices:
The point is that domoticz only create these devices because it is instructed to do so by the zigbee2mqtt module. So if you want a 4th device to be created the zigbee2mqtt module must be updated to add that request.

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 14:05
by kitopopo
And due to the value of strenght appears in the domoticz log, is there no other way to use this value without the need to generate a fourth device? If there is no other solution then I will contact @koenkk.

Thank you

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 14:19
by EddyG
I added a flow in Nodered. This way you can get the data into Domoticz in a Custom sensor.
I made a request in https://github.com/stas-demydiuk/domoti ... gin/issues to support at minimum the 'strength'

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 14:21
by waaren
kitopopo wrote: Monday 04 May 2020 14:05 And due to the value of strenght appears in the domoticz log, is there no other way to use this value without the need to generate a fourth device? If there is no other solution then I will contact @koenkk.
other options:
  • extend the Selector device with more Vibrate levels (vibrate_low, vibrate_moderate, vibrate_strong, vibrate_extreme);
  • send the strength value to a separate variable;
  • send the strength value to the current signal device;
  • send the strength value as customEvent and trigger a dzVents script with it;
  • send the strength value to the description field of the selector device;
  • use an external MQTT broker to intercept the MQTT and send additional data to domoticz;
  • use a script to monitor the log file every xx seconds to see if a line with strength in it was logged.
In my book these are all just workarounds for something that can be fixed using a new device.

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 14:35
by EddyG
waaren wrote: Monday 04 May 2020 14:21
  • use an external MQTT broker to intercept the MQTT and send additional data to domoticz;
In my book these are all bad workarounds for something that should be fixed using a new device
This is not really a BAD workaround, it is customizing my Domoticz. ;)
I do it several times, for instance when a device generated Temp/Hum/Pressure (Xiaomi)
I do not want such a device, but just a Temp/Hum and a Barometer device.

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 14:50
by waaren
EddyG wrote: Monday 04 May 2020 14:35 This is not really a BAD workaround, it is customizing my Domoticz. ;)
I agree and changed the wording in my post :)

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 14:53
by kitopopo
Now i have the vibration sensor in the vibration_extreme and the sensor detects a vibration every 5 minutes aproxx, i need use the strenght value.

What would be the easiest solution on your list for a user who does not have much experience? customEvent or separate variable?
How i can send the strenght value to a separate variable? where i can found information?

Thanks again

Re: Vibration sensor dzvents (zigbee2mqtt)  [Solved]

Posted: Monday 04 May 2020 15:04
by waaren
kitopopo wrote: Monday 04 May 2020 14:53 What would be the easiest solution on your list for a user who does not have much experience? customEvent or separate variable?
These alternatives require an update of zigbee2MQTT so probably easier to ask directly for the creation of a device to receive the strength.
  • send the strength value to a separate variable;
  • send the strength value to the current signal device;
  • send the strength value as customEvent and trigger a dzVents script with it;
  • send the strength value to the description field of the selector device;
This requires nodered or an alternative MQTT broker
  • use an external MQTT broker to intercept the MQTT and send additional data to domoticz;

Re: Vibration sensor dzvents (zigbee2mqtt)

Posted: Monday 04 May 2020 15:21
by kitopopo
thanks, I will request this to @koenkk,

Thanks for your help.

Best regards