to rookie to get it...

Moderator: leecollings

Post Reply
bozidar
Posts: 19
Joined: Saturday 09 September 2017 16:17
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

to rookie to get it...

Post by bozidar »

Hi all

I have in rooms that are mainly controlled by PIR a need for more control.

I am trying to implement that spots dim to 50% light between 20:00 and 2300 and 30% between 23:00 and 5:30 .and 50% between 5:30 and 630

BUT the big issue is light switch need to be able to increase to 100% if pressed and overule dimming.

Light switches are "digital" and ON signal when pressed ,and otherwise off.

Is that even possible
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: to rookie to get it...

Post by waaren »

bozidar wrote: Monday 18 March 2019 19:34 I have in rooms that are mainly controlled by PIR a need for more control.
I am trying to implement that spots dim to 50% light between 20:00 and 2300 and 30% between 23:00 and 5:30 .and 50% between 5:30 and 630
BUT the big issue is light switch need to be able to increase to 100% if pressed and overrule dimming.
Light switches are "digital" and ON signal when pressed ,and otherwise off.
Could be something like

Code: Select all

-- Time & Switch control

dim50Evening = "at 20:00"
dim30Night   = "at 23:00"
dim50Morning = "at 5:30"
Off          = "at 6:30"

return {
    on      =   {     timer =   {
                                    dim50Evening,
                                    dim30Night,
                                    dim50Morning,
                                    Off,
                                },
                
                devices     =   { 
                                    "your Switch", 
                                },
                },
    
    logging =   { level     =   domoticz.LOG_DEBUG, 
                  marker    =   "Time & Switch control" },
    
    data    = { dimLevel    =   { initial = 50 }},

    execute = function(dz,item)
        local light = dz.devices("your dimmable light")
        
        local function logWrite(str,level)
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end
        
        if item.isTimer then 
            if dz.time.matchesRule(dim50Evening) or dz.time.matchesRule(dim50Morning) then
                dz.data.dimLevel = 50
            elseif dz.time.matchesRule(dim30Night) then
                dz.data.dimLevel = 30
            else
                dz.data.dimLevel = 0
            end
            light.dimTo(dz.data.dimLevel)
        else					        	          -- triggered by Switch 
            if item.state == "On" then 	        	  -- Switch is On
                dz.data.dimLevel = light.level   	  -- store current Level
                light.dimTo(100)                  	          -- full Power to the light  
            else
                light.dimTo(dz.data.dimLevel)     -- Restore to old dimLevel  
            end
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest