Period of time between LUA script executions
Posted: Saturday 24 August 2019 17:56
I am new in LUA programming, so my question. Below is a little script to light LED on if entrace gate are open and tun it off when closed. As I understand, Domoticz runs such script every minute. That is what I want. Its because it sends WGET command each minute, it restore status of LED in case of power failure or other problems. RPi on which Domoticz is installed has UPS but remote unis (easyESP) where I send WGET - no.
I am right or not?
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