Hi Guys,
Want to start getting into dzvents rather than blocky, first thing I would like to do is turn a light switch on or off depending on PIR activation order.
I have 2 pir’s, landing2 and landing3, what I would like to do is turn suite lights on if landing2 PIR triggered first then landing3, or if landing3 PIR triggered first then landing2 second turn suite lights off.
I really don’t have a clue, have read up on some dzvents on the domoticz website, back can’t see anyth8ng close to this.
Could anyone help me with the code please.
Thanks
Phil
Turn lights on/off with PIR activation order.
Moderator: leecollings
- madpatrick
- Posts: 670
- Joined: Monday 26 December 2016 12:17
- Target OS: Linux
- Domoticz version: 2025.1
- Location: Netherlands
- Contact:
Re: Turn lights on/off with PIR activation order.
There is a lot of information on the forum you can use. Just read the scripts and you will learn quickly
Here is a basic start to try
Adjust it to your setup
Here is a basic start to try
Adjust it to your setup
Code: Select all
local scriptVersion = 'Versie 1.0 '
local scriptVar = '-=# Script name #=-'
return {
on = {
devices = {300, 400} --Replace number by the device you want to use as a trigger
},
logging = { level = domoticz.LOG_INFO,
marker = scriptVar },
execute = function(dz, device)
local lamp1 = dz.devices(100) --Replace by device number
local lamp1 = dz.devices(100) --Replace by device number
local PIR1 = dz.devices(300) --Replace by device number
local PIR2 = dz.devices(400) --Replace by device number
if PIR1.state == "On" then
lamp1.switchOn().checkFirst()
lamp2.switchOn().checkFirst().AfterSec(10)
dz.log('Lamps are ON', dz.LOG_FORCE)
elseif PIR2.state == "On" and lamp1.state=="On" then
lamp1.switchOff()
end
end
}
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-
Who is online
Users browsing this forum: No registered users and 1 guest