I am right or not?
Code: Select all
local sensor = 'Brama - status'
t1 = os.time()
s = otherdevices_lastupdate[sensor]
year = string.sub(s, 1, 4)
month = string.sub(s, 6, 7)
day = string.sub(s, 9, 10)
hour = string.sub(s, 12, 13)
minutes = string.sub(s, 15, 16)
seconds = string.sub(s, 18, 19)
commandArray = {}
t2 = os.time{year=year, month=month, day=day, hour=hour, min=minutes, sec=seconds}
difference = (os.difftime (t1, t2))
--
-- wlaczenie LED jezeli brama otwarta dluzej niz 25 min
if (otherdevices[sensor] == 'Open' and difference > 1500 and difference < 99999) then
os.execute ("/usr/bin/wget -q -O - http://192.168.0.29/control?cmd=event,LED_on")
-- elseif (devicechanged[sensor] == 'Closed') then
elseif (otherdevices[sensor] == 'Closed' and difference > 1 and difference < 99999) then
os.execute ("/usr/bin/wget -q -O - http://192.168.0.29/control?cmd=event,LED_off")
end
return commandArray