Hi everyone
I have aqara switch button (wireless) that can transmit only single presses. If I hold it pressed - the switch in domoticz also still turned on
But i need to detect this long presses for several seconds and, as bonus, detect also short presses if the button is released shortly.
I have tried to make it with the blockly, but it works slowly and unstable.
May it possible to do with dzvents/LUA?
Actually I haven't knowleges to make any script with dzvents.
Hold button detection script
Moderator: leecollings
-
Antikillerbm
- Posts: 8
- Joined: Sunday 01 April 2018 17:30
- Target OS: Linux
- Domoticz version:
- Contact:
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Hold button detection script
Not fully tested because I do not own such a switch but with an emulated push button it seems to do the job. Please test and report your findings.Antikillerbm wrote: Saturday 01 September 2018 21:07 I have aqara switch button (wireless) that can transmit only single presses. If I hold it pressed - the switch in domoticz also still turned on
But i need to detect this long presses for several seconds and, as bonus, detect also short presses if the button is released shortly.
Thx
Code: Select all
return {
on = { devices = { "Hold button" }},
logging = { level = domoticz.LOG_DEBUG,
marker = "Hold button detection" },
data = { lastState = { initial = "Off" }},
execute = function(dz,triggerObject)
if triggerObject.state == "On" then
dz.log(triggerObject.name .. " switched On",dz.log_DEBUG)
elseif triggerObject.state == "Off" and dz.data.lastState == "On" then
dz.log( triggerObject.name .. " switched Off." .. " It was switched on " ..
triggerObject.lastUpdate.millisecondsAgo .. " milli-Seconds ago.",dz.log_DEBUG)
end
dz.data.lastState = triggerObject.state
end
}Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
Antikillerbm
- Posts: 8
- Joined: Sunday 01 April 2018 17:30
- Target OS: Linux
- Domoticz version:
- Contact:
Re: Hold button detection script
Earlier, I did without this script but now Im realy need it.
Finally I tested it, but it worsk too slowly
When I pushing the button fast several times (with 200-500ms pause) script can get summary time of several clicks and decides that is one long click.
Also im tried to delete logging but it doesnt help.
Finally I tested it, but it worsk too slowly
When I pushing the button fast several times (with 200-500ms pause) script can get summary time of several clicks and decides that is one long click.
Also im tried to delete logging but it doesnt help.