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