Smanar / Domoticz-deCONZ

deCONZ plugin for Domoticz (Zigbee application)
GNU General Public License v3.0
36 stars 27 forks source link

Release of button not as event posted #24

Closed HackThatNow closed 5 years ago

HackThatNow commented 5 years ago

Pressing a Aqara switch, give intimidate event to domoticz about the pressed state. However, when the button is released, this is not event based but poll based as it is updated at "onHeartbeat ".

This creates a problem when using the Aqara switch as a toggle button for a light; pressing the Aqara button, triggers the Blocky to execute the function to toggle the light. But the Blocky gets executed many times until the Aqara switch state is changed by OnHeartbeat to released.

2019-07-10 15:05:42.435 (Deconz) onHeartbeat called 2019-07-10 15:05:42.436 (Deconz) ### Update device (Deconz - Transmitter 2-gang) : {'nValue': 0, 'sValue': 'Off'}

Smanar commented 5 years ago

The "release mode " is something I have made for me, in the normal working mode only the last button event value is used and memorised. There is not "reset" value used with "onHeartbeat". Some device have a button event on press, other on release, and some both.

But I don't unserstand your bug. If I keep the button pressed for 3s, I have only 1 button event with the good button number (and in my case I have it when I release the button) And after I only have 1 notification, you need to use the "on device change fonction"

It's that I m using with LUA > https://github.com/Smanar/Domoticz-deCONZ/wiki/Examples-to-use-LUA-script-for-switch

On the code, the plugin generate a notification.

On the documentation blockly works same "If a change on a device like a switch should start the script. Use "Device" Ex. Turning on a light after sunset. the switch(device) trigger the script and you can check if time is after sunset to trigger something. " So if you have the same button value for 10s, you will have only 1 trigger.

If it don't working pls show me you blockly code to make a try on my side.

HackThatNow commented 5 years ago

Thanks for sending a reply so early, good work! I tested the LUA code, and that works exactly how I want it to work!! Awesome!! Thanks.

I think, this is not possible in Blockly because there is no option to wait for "devicechanged". If a device change, the Blockly is executed many times until the "onHeartbeat" clears the device. But, I love LUA anyway, so I continue with that. Was experimenting with Blockly but I think that is not the way to go for me.

This can close.

Smanar commented 5 years ago

NP, but it's realy strange, I have never used blockly so I don't know it at all, but if there isn't this kind of feature, blockly is totally unusable, I m sure there is a special trick for that.

Edit: I have found a special combobox in the toolbar, with it you can set your blockly code in all/device/timer/variable/security mode, I think the "device" mode will work.