Page 1 of 1

Help With PIR No motion

Posted: Sunday 23 February 2020 19:21
by BladeM3
I've searched in many posts wikis etc and i got confused
There are many examples in lua which i find more difficult than dzvents (just managed to make 1 simple script with switch click to toggle group lights thanks to waaren! ) and a lot of scripts that make to complicated stuff so it's difficult to remove some functions

is there any example to help please?

if no PIR1 motion is not detected for 5 mins and Door_sensor switches to ON then Switch on Living_room lights (group)

Re: Help With PIR No motion

Posted: Sunday 23 February 2020 19:43
by waaren
BladeM3 wrote: Sunday 23 February 2020 19:21 is there any example to help please?
if no PIR1 motion is not detected for 5 mins and Door_sensor switches to ON then Switch on Living_room lights (group)
One more example..

Code: Select all

return 
{
    on = 
    {
        devices = 
        {
            'Door_sensor',
        }
    },
    
    logging = 
    {
        level = domoticz.LOG_DEBUG,
        marker = "Door PIR"
    },

    execute = function(dz, item)
        if item.active then
            local PIR1 = dz.devices('PIR1')
            if not(PIR1.active) and PIR1.lastUpdate.secondsAgo > 300 then
                dz.groups('Living_room lights').switchOn()
            end
        end
    end
}

Re: Help With PIR No motion  [Solved]

Posted: Sunday 23 February 2020 20:06
by BladeM3
REALLY? it was so simple? im reading all day for this too with time stamps and time difference checking and so complex things .. Thank GOD You are a saviour!!!! Thank you so much! Now i can make most of the scripts i need with the rest of the devices!