Page 1 of 1

(Solved)Programming Hallway lamp issue

Posted: Thursday 25 November 2021 14:18
by Bospieper
Hi,
Need some help with a programming issue.
I have a hallway light wich go's On at sunset en Off at 02.00. It's a colored light and it is dimmed to 15%.
What I want if a person is at the frontdoor the hallway light must light up to 70% for 2 minutes.
It is done by a infrared motion sensor. I've tried with the knowledge I have to program this but I don't get it working.
So some help would be appreciated.

Code: Select all

return {
	on = {
		timer = 
		{
		    'between 10 minutes before sunset and 23:30',
		    'between 23:30 and 02:00',
		    'at 02:00',
		                        },
        devices =
        {
            'color',
            'sensor'
            
        },
        
    },

    logging =
    {
        level = domoticz.LOG_ERROR, -- set to domoticz.LOG_INFO when all ok
        marker = 'Lamp gang',
    },

    execute = function(dz, item )

            local master = dz.devices('Kamer- masterswitch') -- virtual switch to trigger a Scene that will switch all lights off
                 if master.active then
                 dz.log('Rest of script will be ignored because master switch is activated and every light should stay off',dz.LOG_INFO )
                 return
            end
            
        local color = dz.devices('Gang- Kleurinstelling gang')
        local sensor = dz.devices('Beweging sensor gang')
       
       
        if dz.time.matchesRule('between 10 minutes before sunset and 23:30') then
           color.setColor(253,244,220,15,0,0,4,0)
            
              
        elseif dz.time.matchesRule('between 23:30 and 02:00') then
            color.setColor(0,255,0, 10, 0, 0, 4, 0)
                 
        elseif dz.time.matchesRule('at 02:00') then
            color.switchOff().checkFirst()
           
        end
       
end
}			
		

Re: Programming Hallway lamp issue

Posted: Thursday 25 November 2021 16:14
by waltervl
Try to change

Code: Select all

devices =
        {
            'color',
            'sensor'
            
        },
to below so it will trigger on sensor changes only

Code: Select all

devices =
        {
            'Beweging sensor gang'
            
        },
And check for sensor.active (doc: active: Boolean. Is true for some common states like ‘On’ or ‘Open’ or ‘Motion’) eg

Code: Select all

 if sensor.active then color.setColor(.....).forMin(2)

Re: Programming Hallway lamp issue

Posted: Thursday 25 November 2021 17:26
by Bospieper
Thanx Waltervl, I will try that, hadden't thought of this option.

Re: Programming Hallway lamp issue

Posted: Thursday 25 November 2021 17:46
by Bospieper
Hi,
It's not working, from the Dzvents documentation it said that in case of RGB devices you have to use other command like forAAA()

.../domoticz/scripts/dzVents/generated_scripts/Lampgang.lua:36: attempt to call a nil value (field 'forMin')

Re: Programming Hallway lamp issue

Posted: Thursday 25 November 2021 18:10
by waltervl
Then do something like

Code: Select all

 if sensor.active then 
           color.setColor(70%)
           color.setcolor(15%).afterMin(2)
end

(SOLVED) Programming Hallway lamp issue

Posted: Thursday 25 November 2021 21:10
by Bospieper
Hi Waltervl,
You can ignore my previeus post. I had an <end> in the programming at the wrong place.
It's working, thanx.
Solution was very easy if you know programming ;)
Grz. Piet