Help With PIR No motion  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
BladeM3
Posts: 6
Joined: Thursday 20 February 2020 9:20
Target OS: -
Domoticz version:
Contact:

Help With PIR No motion

Post 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)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Help With PIR No motion

Post 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
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
BladeM3
Posts: 6
Joined: Thursday 20 February 2020 9:20
Target OS: -
Domoticz version:
Contact:

Re: Help With PIR No motion  [Solved]

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

Who is online

Users browsing this forum: No registered users and 1 guest