-- demo time script -- script names have three name components: script_trigger_name.lua -- trigger can be 'time' or 'device', name can be any string -- domoticz will execute all time and device triggers when the relevant trigger occurs -- -- copy this script and change the "name" part, all scripts named "demo" are ignored. -- -- Make sure the encoding is UTF8 of the file -- -- ingests tables: otherdevices,otherdevices_svalues -- -- otherdevices and otherdevices_svalues are two item array for all devices: -- otherdevices['yourotherdevicename']="On" -- otherdevices_svalues['yourotherthermometer'] = string of svalues -- -- Based on your logic, fill the commandArray with device commands. Device name is case sensitive. -- -- Always, and I repeat ALWAYS start by checking for a state. -- If you would only specify commandArray['AnotherDevice']='On', every time trigger (e.g. every minute) will switch AnotherDevice on. -- -- The print command will output lua print statements to the domoticz log for debugging. -- List all otherdevices states for debugging: -- for i, v in pairs(otherdevices) do print(i, v) end -- List all otherdevices svalues for debugging: -- for i, v in pairs(otherdevices_svalues) do print(i, v) end print('this will end up in the domoticz log') t1 = os.time() s = otherdevices_lastupdate['Garagedoor'] -- returns a date time like 2013-07-11 17:23:12 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)) if (otherdevices['Garagedoor'] == 'Open' and difference > 600 and difference < 700) then commandArray['SendNotification']='Garage door alert#The garage door has been open for more than 10 minutes!' end return commandArray