Light off after x minutes no motion

Moderator: leecollings

Post Reply
RezaRose
Posts: 65
Joined: Sunday 09 February 2020 11:34
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Holland
Contact:

Light off after x minutes no motion

Post by RezaRose »

Hi there,

I tried to make a script that does the lights on when there is motion in the shed. I have a motion sensor and a light in the shed, and in the garden i have outdoorlights.

The lights turn on when i open the shed, but they will not go out. I am not a programmer but i am learning, Still finding the optimal way to write a script. What am i doing wrong here?

I tested everything before i installed the lights and sensor. It worked.

--Niemand Thuis = Nobody is Home
--Zon is op = Day or nighttime

Sensor = 'Schuursensor'
Licht1 = 'Tuinverlichting' --gardenlights
Licht2 = 'Schuur' --shedlights

commandArray = {}
if (devicechanged[Sensor] == 'On') and (otherdevices['Niemand thuis'] == 'On') then
commandArray['SendNotification']='Niemand thuis#ER IS BEWEGING IN DE SCHUUR####pushbullet;email'
commandArray[Licht1] = "On FOR 1 SECONDS REPEAT 30 INTERVAL 2 SECONDS"
print("************ BEWEGING IN DE SCHUUR GEDETECTEERD ***************")

elseif (devicechanged[Sensor] == 'On') and (otherdevices['De zon is op'] == 'Off') then
commandArray[Licht1] = 'On FOR 5'
commandArray[Licht2] = 'On FOR 5'
print("************ Tuinlicht gaat aan omdat er beweging in de schuur is. ***************")

elseif (devicechanged[Sensor] == 'On') and (otherdevices['De zon is op'] == 'On') then
commandArray[Licht2] = 'On FOR 5'
print("************ Schuurlicht gaat aan omdat er beweging in de schuur is. ***************")


end
Raspberry Pi 4 - Raspbian bullseye - Python 3.9 - stable
Dashticz on apache2 - Mqqt - node red
Zigate - USB Tll - Philips hue - Ikea - Innr - Xiaomi - TPlink - Nest -v3
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest