Page 1 of 1

Dzvents trigger on level ??

Posted: Saturday 12 June 2021 14:57
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

Re: Dzvents trigger on level ??

Posted: Saturday 12 June 2021 19:28
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