Page 1 of 1

PIR activated - Light on for 1 minute at 50%

Posted: Sunday 11 February 2018 11:36
by htilburgs
Domoticz v3.8914
Fibaro Motion Sensor FGMS001

What I'm trying to do is to switch the hall light for 1 minute at 50% when PIR is activated between 23:00 and 06:30.
dzVents script:

Code: Select all

return {
    on = 
    {
        devices = 
            {['PIR - Trap'] = {'between 23:00 and 06:30'}},
            'Lamp Gang'
    },
    execute = function(domoticz, device)
        if 
            {(device.name == 'PIR - Trap' and device.state == 'On') and
            (device.name == 'Lamp Gang' and device.state == 'Off')}
        then
            domoticz.devices('Lamp Gang').dimTo(50).forMin(1)
            domoticz.log('Lamp zolder ingeschakeld door PIR Trappenhuis')
        end
    end
}
Sometimes this works, but most of the time the light stays on. I've seen in the dzVents examples that this may be the case and I'll have to use something like

Code: Select all

light.switchOff().checkFirst().afterMin(5)
light.switchOn().checkFirst().forMin(5)
but that this doesn't work in combination with .dimTo()

So for now I'm stuck and I can't get this to work.
Any help would be appreciated....

Re: PIR activated - Light on for 1 minute at 50%

Posted: Monday 12 February 2018 18:13
by dannybloe
checkFirst() is nothing more than an encapsulated if-statement so leave out the checkFirst and do the check using an if-statement

Code: Select all

if (light.active) then
	light.switchOff().afterMin(5)
else
	light.switchOn().forMin(5)
end
And you can better use the dzVents sub-forum.