PIR activated - Light on for 1 minute at 50%

Moderator: leecollings

Post Reply
User avatar
htilburgs
Posts: 464
Joined: Tuesday 03 November 2015 11:01
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

PIR activated - Light on for 1 minute at 50%

Post 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....
Hardware:
RPi3 - Aeon Labs Z-Stick GEN5 - Fibaro Dimmer 2 - Fibaro Roller Shutter 2 - Fibaro Smoke Sensor - Yeelight RGBW Led bulb - Yeelight Smart LED Light Strip - Neo Coolcam PIR Motion Sensor - Neo Coolcam PowerPlug - Nest Thermostat v3
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

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

Post 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.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest