Page 1 of 1

Light off after x minutes no motion

Posted: Wednesday 03 June 2020 13:17
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