help with dimming 100 > 10 and back via "Hold" switch  [Solved]

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

Moderator: leecollings

Post Reply
bradsystem
Posts: 2
Joined: Wednesday 29 April 2020 22:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

help with dimming 100 > 10 and back via "Hold" switch

Post by bradsystem »

hello members :)

im newbie with dzVents,..

on/off light with "click" is ok
with "hold" reducing light to 10% is also ok
with this script:

Code: Select all

return {

   on = { devices = { 62 }},        -- Name of your button
               
   execute = function(dz, item )
        if item.state == "Click" then
            dz.devices(55).toggleSwitch()      -- Name of your light
        elseif item.state == "Hold" then
            dz.devices(55).dimTo(10)    -- Name  of your light
        end
   end
}
but i want with next "hold" to recover light output to 100%
or "click" always toggle light to 100% from off
(one of these methodes)

thxx brad
sry for my english
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: help with dimming 100 > 10 and back via "Hold" switch

Post by waaren »

bradsystem wrote: Wednesday 29 April 2020 23:29 on/off light with "click" is ok. With "hold" reducing light to 10% is also ok

but i want with next "hold" to recover light output to 100%
or "click" always toggle light to 100% from off
Not sure if this is what you want but can you give it a try?

Code: Select all

return 
{
    on = 
    { 
        devices = 
        { 
            62,        -- 'Name' or idx of your button
        },
    }, 
               
   execute = function(dz, item )
        local light = dz.devices(55)
        if item.state == "Click" and light.state == 'Off' then
            light.dimTo(100)
        elseif item.state == 'Click' then 
            light.dimTo(1)
            light.dimTo(0).afterSec(0.3)
        elseif item.state == "Hold" and light.state == 'Off' or light.level < 50  then
            light.dimTo(100)
        elseif item.state == "Hold" and light.level > 50  then
            light.dimTo(10)
        end
   end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
bradsystem
Posts: 2
Joined: Wednesday 29 April 2020 22:13
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: help with dimming 100 > 10 and back via "Hold" switch  [Solved]

Post by bradsystem »

hello waaren,

WOW.. works by both ways.. "hold" high>low>high.... and click also restore light to high from low>off..

thx alot !!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest