Blame | Last modification | View Log | Download
---- Domoticz passes information to scripts through a number of global tables---- device changed contains state and svalues for the device that changed.-- devicechanged['yourdevicename'] = state-- devicechanged['svalues'] = svalues string---- 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 = {}-- loop through all the changed devicesfor deviceName,deviceValue in pairs(devicechanged) doprint ("Device based event fired on '"..deviceName.."', value '"..tostring(deviceValue).."'");-- if (deviceName=='myDevice') then-- if deviceValue == "On" then-- print("Device is On")-- elseif deviceValue == "Off" then-- commandArray['a device name'] = "On"-- commandArray['another device name'] = "Off AFTER 10"-- commandArray['Scene:MyScene'] = "Off"-- commandArray['Group:My Group'] = "Off AFTER 30"-- end-- endendreturn commandArray