<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=LUA_commands</id>
	<title>LUA commands - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=LUA_commands"/>
	<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=LUA_commands&amp;action=history"/>
	<updated>2026-09-18T23:45:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.domoticz.com/index.php?title=LUA_commands&amp;diff=19037&amp;oldid=prev</id>
		<title>Walter vl: /* General */</title>
		<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=LUA_commands&amp;diff=19037&amp;oldid=prev"/>
		<updated>2025-12-19T14:23:38Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;General&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:23, 19 December 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l74&quot;&gt;Line 74:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 74:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    commandArray[&amp;#039;OpenURL&amp;#039;]=&amp;#039;www.yourdomain.com/api/movecamtopreset.cgi&amp;#039;  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    commandArray[&amp;#039;OpenURL&amp;#039;]=&amp;#039;www.yourdomain.com/api/movecamtopreset.cgi&amp;#039;  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    commandArray[#commandArray + 1] = { OpenURL = url .. &amp;#039; AFTER 0.2&amp;#039; } -- send the url after 0.2 seconds&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    commandArray[#commandArray + 1] = { OpenURL = url .. &amp;#039; AFTER 0.2&amp;#039; } -- send the url after 0.2 seconds&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    commandArray[&#039;SendNotification&#039;]=&#039;subject#body#&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;0&lt;/del&gt;#sound#extradata#subsystem&#039;  &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    commandArray[&#039;SendNotification&#039;]=&#039;subject#body#&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;priority&lt;/ins&gt;#sound#extradata#subsystem&#039;  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;           -- Subject is .. the subject&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;           -- Subject is .. the subject&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;           -- Body is the content of the message&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;           -- Body is the content of the message&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;           -- 0 &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;is the priority that you are talking about&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;           -- &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;priority is a number from &lt;/ins&gt;0 &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(low) to 4 (emergency)&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;           -- sound is the sound you want to use if you use pushover&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;           -- sound is the sound you want to use if you use pushover&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;           -- extradata can be used by some of the notification.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;           -- extradata can be used by some of the notification.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Walter vl</name></author>
	</entry>
	<entry>
		<id>https://wiki.domoticz.com/index.php?title=LUA_commands&amp;diff=17778&amp;oldid=prev</id>
		<title>Walter vl: /* General */ added SendNotification</title>
		<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=LUA_commands&amp;diff=17778&amp;oldid=prev"/>
		<updated>2023-01-03T17:24:03Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;General: &lt;/span&gt; added SendNotification&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
=Lua tables, commands and variables list for use in Domoticz=&lt;br /&gt;
This page is created to give an overview of tables, possible commands and variables in Lua that can be used in Domoticz.&lt;br /&gt;
There is already a lot of information available on the forum, but this is scattered throughout. Next to that, the syntax is not always clear.&lt;br /&gt;
&lt;br /&gt;
See also the [[Events#LUA Scripts|LUA scripts section in the eventsystem page]] for more background info.&lt;br /&gt;
&lt;br /&gt;
==Tables available in your scripts==&lt;br /&gt;
&lt;br /&gt;
===Available in time triggered scripts===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
timeofday&lt;br /&gt;
uservariables&lt;br /&gt;
uservariables_lastupdate&lt;br /&gt;
&lt;br /&gt;
globalvariables&lt;br /&gt;
&lt;br /&gt;
otherdevices&lt;br /&gt;
otherdevices_idx&lt;br /&gt;
otherdevices_lastlevel&lt;br /&gt;
otherdevices_lastupdate&lt;br /&gt;
otherdevices_svalues&lt;br /&gt;
&lt;br /&gt;
-- Below tables only when such devices exist on your system. (else nil)&lt;br /&gt;
otherdevices_barometer&lt;br /&gt;
otherdevices_dewpoint&lt;br /&gt;
otherdevices_humidity&lt;br /&gt;
otherdevices_rain&lt;br /&gt;
otherdevices_rain_lasthour&lt;br /&gt;
otherdevices_temperature&lt;br /&gt;
otherdevices_utility&lt;br /&gt;
otherdevices_weather&lt;br /&gt;
otherdevices_winddir&lt;br /&gt;
otherdevices_windgust&lt;br /&gt;
otherdevices_windspeed&lt;br /&gt;
otherdevices_zwavealarms&lt;br /&gt;
&lt;br /&gt;
otherdevices_scenesgroups&lt;br /&gt;
otherdevices_scenesgroups_idx&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Tables available in device triggered scripts===&lt;br /&gt;
&lt;br /&gt;
All of the tables available in device triggered scripts  &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
devicechanged&lt;br /&gt;
devicechanged_ext&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Tables available in variable triggered scripts===&lt;br /&gt;
&lt;br /&gt;
All of the tables available in variable triggered scripts&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
uservariablechanged&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
commandArray = {}&lt;br /&gt;
if (devicechanged[&amp;#039;MyDeviceName&amp;#039;] == &amp;#039;On&amp;#039; and otherdevices[&amp;#039;MyOtherDeviceName&amp;#039;] == &amp;#039;Off&amp;#039;) then&lt;br /&gt;
   commandArray[&amp;#039;MyOtherDeviceName1&amp;#039;]=&amp;#039;On&amp;#039;&lt;br /&gt;
   commandArray[&amp;#039;MyOtherDeviceName2&amp;#039;]=&amp;#039;On&amp;#039;&lt;br /&gt;
   commandArray[&amp;#039;MyOtherDeviceName3&amp;#039;]=&amp;#039;Off&amp;#039;&lt;br /&gt;
   commandArray[&amp;#039;MyOtherDeviceName4&amp;#039;]=&amp;#039;On FOR 10&amp;#039; -- minutes&lt;br /&gt;
   commandArray[&amp;#039;MyOtherDeviceName5&amp;#039;]=&amp;#039;Off RANDOM 30&amp;#039; -- random within x minutes&lt;br /&gt;
   commandArray[&amp;#039;MyOtherDeviceName6&amp;#039;]=&amp;#039;On REPEAT 5 INTERVAL 5&amp;#039; -- command will be repeated 5 times with 5 seconds interval&lt;br /&gt;
   commandArray[&amp;#039;MyOtherDeviceName7&amp;#039;] = &amp;quot;On FOR 2 SECONDS REPEAT 9 INTERVAL 4 SECONDS&amp;quot; -- every 4 seconds and do that 9 times, put device On for 2 seconds&lt;br /&gt;
   commandArray[&amp;#039;MyBlind&amp;#039;]=&amp;#039;Open&amp;#039;&lt;br /&gt;
   commandArray[&amp;#039;Scene:MyScene&amp;#039;]=&amp;#039;On&amp;#039;&lt;br /&gt;
   commandArray[&amp;#039;Group:MyGroup&amp;#039;]=&amp;#039;Off AFTER 30&amp;#039; -- seconds&lt;br /&gt;
   commandArray[#commandArray + 1] = { SendNotification = &amp;#039;subject#body#prio#sound#extraData#subSystem1;subSystem2;subSystem3&amp;#039;&lt;br /&gt;
   commandArray[&amp;#039;OpenURL&amp;#039;]=&amp;#039;www.yourdomain.com/api/movecamtopreset.cgi&amp;#039; &lt;br /&gt;
   commandArray[#commandArray + 1] = { OpenURL = url .. &amp;#039; AFTER 0.2&amp;#039; } -- send the url after 0.2 seconds&lt;br /&gt;
   commandArray[&amp;#039;SendNotification&amp;#039;]=&amp;#039;subject#body#0#sound#extradata#subsystem&amp;#039; &lt;br /&gt;
          -- Subject is .. the subject&lt;br /&gt;
          -- Body is the content of the message&lt;br /&gt;
          -- 0 is the priority that you are talking about&lt;br /&gt;
          -- sound is the sound you want to use if you use pushover&lt;br /&gt;
          -- extradata can be used by some of the notification.&lt;br /&gt;
          -- subsystem is one or more of: clickatell;email;fcm;http;kodi;lms;prowl;pushalot;pushbullet;pushover;pushsafer;telegram&lt;br /&gt;
   commandArray[&amp;#039;SendEmail&amp;#039;]=&amp;#039;subject#body#to&amp;#039;&lt;br /&gt;
   commandArray[&amp;#039;TriggerIFTTT&amp;#039;]=&amp;#039;EventName#Value1#Value2#Value3&amp;#039;&lt;br /&gt;
   commandArray[&amp;#039;Variable:MyVar&amp;#039;]=&amp;#039;Some value&amp;#039;&lt;br /&gt;
   commandArray[Text:1234]=&amp;#039;Some value&amp;#039;&lt;br /&gt;
   commandArray[&amp;#039;SetSetPoint:MySetPointIdx&amp;#039;]=&amp;#039;20.5&amp;#039;&lt;br /&gt;
   commandArray[&amp;#039;SendCamera:1&amp;#039;] = &amp;#039;SubjectOfMessage AFTER 5&amp;#039; -- This is equal to &amp;#039;Send camera snapshot with subject &amp;quot;Subject of Message&amp;quot; after 5 seconds. The number (1) in this case is the ID of the camera, not the name!&lt;br /&gt;
   commandArray[&amp;#039;UpdateDevice&amp;#039;]=&amp;#039;idx|nValue|sValue&amp;#039; -- for updating Dummy devices e.g. &amp;#039;96|0|Hello World&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
return commandArray&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Round function===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
local function round(num, dec)&lt;br /&gt;
	return ( math.floor( num * 10^dec ) / 10^dec )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Update multiple devices in one pass===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
commandArray = {}&lt;br /&gt;
local function update(idx, value1, value2)&lt;br /&gt;
    local cmd = string.format(&amp;quot;%d|0|%.2f;%.2f&amp;quot;, idx, value1, value2)&lt;br /&gt;
    table.insert (commandArray, { [&amp;#039;UpdateDevice&amp;#039;] = cmd } )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
update (16, 320, 0)&lt;br /&gt;
update (19, 4, 25)&lt;br /&gt;
return commandArray&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Update (one or more) numerical devices without using the device idx code===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
commandArray = {}&lt;br /&gt;
&lt;br /&gt;
local function updatenum(dev, value1)&lt;br /&gt;
    local cmd = string.format(&amp;quot;%d|0|%d&amp;quot;, otherdevices_idx[dev], value1)&lt;br /&gt;
    table.insert (commandArray, { [&amp;#039;UpdateDevice&amp;#039;] = cmd } )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- example 1: increment a counter&lt;br /&gt;
updatenum(&amp;#039;Counter1&amp;#039;, tonumber(otherdevices[&amp;#039;Counter1&amp;#039;]) + 1)&lt;br /&gt;
&lt;br /&gt;
-- example 2: set a fixed value&lt;br /&gt;
updatenum(&amp;#039;Counter2&amp;#039;, 85)&lt;br /&gt;
&lt;br /&gt;
return commandArray&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Debugging==&lt;br /&gt;
&lt;br /&gt;
===Function to dump all variables supplied to the script===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function LogVariables(x,depth,name)&lt;br /&gt;
    for k,v in pairs(x) do&lt;br /&gt;
        if (depth&amp;gt;0) or ((string.find(k,&amp;#039;device&amp;#039;)~=nil) or (string.find(k,&amp;#039;variable&amp;#039;)~=nil) or &lt;br /&gt;
                         (string.sub(k,1,4)==&amp;#039;time&amp;#039;) or (string.sub(k,1,8)==&amp;#039;security&amp;#039;)) then&lt;br /&gt;
            if type(v)==&amp;quot;string&amp;quot; then print(name..&amp;quot;[&amp;#039;&amp;quot;..k..&amp;quot;&amp;#039;] = &amp;#039;&amp;quot;..v..&amp;quot;&amp;#039;&amp;quot;) end&lt;br /&gt;
            if type(v)==&amp;quot;number&amp;quot; then print(name..&amp;quot;[&amp;#039;&amp;quot;..k..&amp;quot;&amp;#039;] = &amp;quot;..v) end&lt;br /&gt;
            if type(v)==&amp;quot;boolean&amp;quot; then print(name..&amp;quot;[&amp;#039;&amp;quot;..k..&amp;quot;&amp;#039;] = &amp;quot;..tostring(v)) end&lt;br /&gt;
            if type(v)==&amp;quot;table&amp;quot; then LogVariables(v,depth+1,k); end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
-- call with this command&lt;br /&gt;
LogVariables(_G,0,&amp;#039;&amp;#039;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Function to dump content of any table===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local function tprint (t, indent, done) -- introduced done to prevent infinite loops for tables with self-references&lt;br /&gt;
  local done = done or {} &lt;br /&gt;
  indent = indent or 0&lt;br /&gt;
  for key, value in pairs (t) do&lt;br /&gt;
    pre = (string.rep (&amp;quot; &amp;quot;, indent)) -- indent it&lt;br /&gt;
    if type (value) == &amp;quot;table&amp;quot; and not done[value] then&lt;br /&gt;
      done [value] = true&lt;br /&gt;
      print (pre .. tostring (key) .. &amp;quot;:&amp;quot;);&lt;br /&gt;
      tprint (value, indent + 2, done)&lt;br /&gt;
    elseif type(value) == &amp;#039;function&amp;#039; and not done[value] then&lt;br /&gt;
      print( pre .. (tostring (key) .. &amp;quot;()&amp;quot;))&lt;br /&gt;
    else&lt;br /&gt;
      pre = pre .. (tostring (key) .. &amp;quot;: &amp;quot;)&lt;br /&gt;
      print (pre .. tostring(value))&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Date and Time==&lt;br /&gt;
&lt;br /&gt;
===Start script at a specific minute===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
commandArray = {}&lt;br /&gt;
local atMinute = 12&lt;br /&gt;
&lt;br /&gt;
if tonumber(os.date(&amp;#039;%M&amp;#039;)) ~= atMinute then&lt;br /&gt;
    print (&amp;#039;Not the right minute. No further execution.&amp;#039;)&lt;br /&gt;
    return commandArray&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Start script at a specific time===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local executionTime = &amp;#039;23:21&amp;#039;&lt;br /&gt;
local light = &amp;#039;Flicker&amp;#039; -- Name of your light&lt;br /&gt;
commandArray = {}&lt;br /&gt;
&lt;br /&gt;
if os.date(&amp;#039;%H:%M&amp;#039;) == executionTime then&lt;br /&gt;
     for i = 0, 12, 2 do&lt;br /&gt;
        commandArray[#commandArray + 1] = { [light] = &amp;#039;Off AFTER &amp;#039; .. i }&lt;br /&gt;
        commandArray[#commandArray + 1] = { [light] = &amp;#039;On AFTER &amp;#039; .. (i + 1) }&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return commandArray&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Function to get timestamp===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local function timestamp(dateString, pattern)&lt;br /&gt;
    if dateString == nil then return os.time() end&lt;br /&gt;
    local pattern = pattern or  &amp;quot;(%d+)%-(%d+)%-(%d+)%s+(%d+):(%d+):(%d+)&amp;quot;&lt;br /&gt;
    local year, month, day, hour, minute, seconds = dateString:match(pattern)&lt;br /&gt;
    return os.time( { year = year, month = month, day = day, hour = hour, min = minute, sec = seconds } )&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Function to calculate the time difference (uses timestamp function)===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function timedifference(t1, t2) -- both dates with format &amp;#039;yyyy-mm-dd HH:MM:SS&amp;#039; or nil&lt;br /&gt;
  return timestamp(t1) - timestamp(t2)&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Usage&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local mydevice_changed = false&lt;br /&gt;
if (mydevice_changed ~= nil and devicechanged[&amp;#039;mydevice&amp;#039;]) then&lt;br /&gt;
    mydevice_changed = true&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
s = otherdevices_lastupdate[&amp;#039;mydevice&amp;#039;]&lt;br /&gt;
if(otherdevices[&amp;#039;mydevice&amp;#039;]==&amp;#039;On&amp;#039; and timedifference(s) &amp;gt; 600 and not mydevice_changed) then&lt;br /&gt;
    commandArray[&amp;#039;mydevice&amp;#039;]=&amp;#039;Off&amp;#039;&lt;br /&gt;
end&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;Note: You should only define and check for mydevice_changed variable when using &amp;#039;All&amp;#039; scripts.&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
===Time of day===&lt;br /&gt;
Check if it is daytime or nighttime&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
if (timeofday[&amp;#039;Daytime&amp;#039;]) then ...&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
if (timeofday[&amp;#039;Nighttime&amp;#039;]) then ...&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Devices==&lt;br /&gt;
&lt;br /&gt;
[[Category:Domoticz]]&lt;br /&gt;
[[Category:Manual]]&lt;br /&gt;
[[Category:Setup]]&lt;br /&gt;
[[Category:Scripting]]&lt;br /&gt;
[[Category:Lua]]&lt;/div&gt;</summary>
		<author><name>Walter vl</name></author>
	</entry>
</feed>