Blame | Last modification | View Log | Download
---- Domoticz passes information to scripts through a number of global tables---- otherdevices, otherdevices_lastupdate and otherdevices_svalues are arrays for all devices:-- otherdevices['yourotherdevicename'] = "On"-- otherdevices_lastupdate['yourotherdevicename'] = "2015-12-27 14:26:40"-- otherdevices_svalues['yourotherthermometer'] = string of svalues---- uservariables and uservariables_lastupdate are arrays for all user variables:-- uservariables['yourvariablename'] = 'Test Value'-- uservariables_lastupdate['yourvariablename'] = '2015-12-27 11:19:22'---- other useful details are contained in the timeofday table-- timeofday['Nighttime'] = true or false-- timeofday['SunriseInMinutes'] = number-- timeofday['Daytime'] = true or false-- timeofday['SunsetInMinutes'] = number-- globalvariables['Security'] = 'Disarmed', 'Armed Home' or 'Armed Away'---- To see examples of commands see: http://www.domoticz.com/wiki/LUA_commands#General-- To get a list of available values see: http://www.domoticz.com/wiki/LUA_commands#Function_to_dump_all_variables_supplied_to_the_script---- Based on your logic, fill the commandArray with device commands. Device name is case sensitive.--commandArray = {}print ("Time based event fired");-- loop through all the devicesfor deviceName,deviceValue in pairs(otherdevices) do-- if (deviceName=='myDevice') then-- if deviceValue == "On" then-- print("Device is On")-- elseif deviceValue == "Off" then-- commandArray['a device name'] = "On"-- commandArray['Scene:MyScene'] = "Off"-- end-- endend-- loop through all the variablesfor variableName,variableValue in pairs(uservariables) do-- if (variableName=='myVariable') then-- if variableValue == 1 then-- commandArray['a device name'] = "On"-- commandArray['Group:My Group'] = "Off AFTER 30"-- end-- endendreturn commandArray