Dzvents trigger on level ??

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

Moderator: leecollings

Post Reply
Biiiiino
Posts: 18
Joined: Monday 19 April 2021 18:15
Target OS: Linux
Domoticz version:
Contact:

Dzvents trigger on level ??

Post by Biiiiino »

Hello,

i have ikea button, which is detected by domoticz as selector which 3 different states:

One short click: Action "on"
Hold button: "brightness_move_up"
Release hold button: "brightness_stop"

My challenge is, i want to use this switch as trigger in dzvents based switch state. For example - One short click - turn on another button (trigger on device in dzvents).
Hold button: move my blinds up (its different button) etc etc....

Now i have this dzvent script:

Code: Select all

return {

   on = { devices = { 'Ikea_button' }},        -- idx of your button
   
   execute = function(dz, item )
        if item.state == "On" then
            dz.devices('test_ikea').toggleSwitch()    
        elseif item.state == "Off" then
            dz.devices('test_ikea').toggleSwitch()    
        else 
            dz.log("state of " .. item.name .. " is now Off")
        end
   end
}
This script is working only when i change device type from Selector to "Push On Button".
If i leave it as selector, nothing happen just "test_ikea" button is still off..


So my question is, is possible trigger dzvents based on different device action?

Thank you in advice
keros
Posts: 77
Joined: Saturday 27 July 2019 0:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Dzvents trigger on level ??

Post by keros »

Just replace "On" and "Off" by the level names.

For example :

Code: Select all

if item.state == 'Click' then
Or using the level number :

Code: Select all

if item.level == 0 then
Moderator on Easydomoticz.com, the French DomoticZ forum.
French writer for ZigBeeForDomoticZ Plugin Wiki
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest