(Solved)Programming Hallway lamp issue

Moderator: leecollings

Post Reply
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

(Solved)Programming Hallway lamp issue

Post 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
}			
		
Last edited by Bospieper on Thursday 25 November 2021 22:20, edited 1 time in total.
User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Programming Hallway lamp issue

Post 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)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Programming Hallway lamp issue

Post by Bospieper »

Thanx Waltervl, I will try that, hadden't thought of this option.
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

Re: Programming Hallway lamp issue

Post 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')
User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Programming Hallway lamp issue

Post by waltervl »

Then do something like

Code: Select all

 if sensor.active then 
           color.setColor(70%)
           color.setcolor(15%).afterMin(2)
end
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
Bospieper
Posts: 166
Joined: Thursday 07 November 2019 10:26
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: NL
Contact:

(SOLVED) Programming Hallway lamp issue

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest