Read device and act on how fast a click has been done

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Read device and act on how fast a click has been done

Post by poudenes »

Hello All,

I have some KaKu Switches used with RFlink and Milight bulbs. In dZvents scripts to link switches with some bulbs.
I want try something new:

1 click turn On : Bulb to normal
2 clicks on ON: Bulb goes into disco
1 click on Off: Bulb goes off

Now im wondering if this can be done in Domoticz Device itself or i need a LUA to do this?
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Read device and act on how fast a click has been done

Post by waaren »

@poudenes

I don' t think it can be done with KlikAan KlikUit switches alone. I do use for something similar the Xiamoi pushbutton link (which has cllick, double click and long click) but for activating different scenes with KlikAan KlikUit switches I have a dzVents script like below. It does not react on how fast the switch is clicked but cycles over a list of scenes.
With the help of the .cancelQueuedCommands() and .afterSec() methods, it possibly could be tweaked a bit further towards your needs.

Code: Select all

return {

   on = { devices = { "your switch"	}           },
   
   data = { currentScene = { initial = 1 }      },
    
   execute = function(dz, switch )
        local myScenes = {"Scene_1","Scene_2","Scene_3","Scene_4"}
        myScenes["Off"]  = "Scene_off"    
        
        if switch.active then
		    dz.scenes(myScenes[dz.data.currentScene]).switchOn()
			dz.data.currentScene =  dz.data.currentScene + 1
            if #scenes > dz.data.currentScene then return end
       else
        	dz.scenes(myScenes["Off"]).switchOn()
        end
        dz.data.currentScene = 1
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Read device and act on how fast a click has been done

Post by poudenes »

Thanks for the script. Simular idea I found also. I maybe go buy meek wifi wall switch. It's programmable and maybe better to use


Verzonden vanaf mijn iPhone met Tapatalk Pro
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest