跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
Wiki首页
Domoticz 中文站
Domoticz 论坛
Domoticz Github
随机页面
特殊页面
特殊页面
所有页面
分类
最近更改
Domoticz
搜索
搜索
登录
个人工具
登录
查看“LUA命令”的源代码
页面
讨论
大陆简体
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
←
LUA命令
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
= LUA commands and variables list for use in Domoticz = This page is created to give an overview of all the possible commands and variables in Lua that can be used in Domoticz. 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. THIS PAGE IS STILL UNDER CONSTRUCTION == General == <syntaxhighlight lang="lua"> commandArray = {} if (devicechanged['MyDeviceName'] == 'On' and otherdevices['MyOtherDeviceName'] == 'Off') then commandArray['MyOtherDeviceName1']='On' commandArray['MyOtherDeviceName2']='On' commandArray['MyOtherDeviceName3']='Off' commandArray['MyOtherDeviceName4']='On FOR 10' -- minutes commandArray['MyOtherDeviceName5']='Off RANDOM 30' -- random within x minutes commandArray['Scene:MyScene']='On' commandArray['Group:MyGroup']='Off AFTER 30' -- seconds commandArray['SendNotification']='subject#body#extraData#priority#sound' commandArray['OpenURL']='www.yourdomain.com/api/movecamtopreset.cgi' commandArray['SendEmail']='subject#body#to' commandArray['Variable:MyVar']='Some value' commandArray['SetSetPoint:MySetPointIdx']='20.5' commandArray['UpdateDevice']='idx|nValue|sValue' -- for updating Dummy devices e.g. '96|0|Hello World' end return commandArray </syntaxhighlight> === Update multiple devices in one pass === <syntaxhighlight lang="lua"> commandArray = {} local function update(idx, value1, value2) local cmd = string.format("%d|0|%.2f;%.2f", idx, value1, value2) table.insert (commandArray, { ['UpdateDevice'] = cmd } ) end update (16, 320, 0) update (19, 4, 25) return commandArray </syntaxhighlight> == Debugging == === Function to dump all variables supplied to the script === <syntaxhighlight lang="lua"> function LogVariables(x,depth,name) for k,v in pairs(x) do if (depth>0) or ((string.find(k,'device')~=nil) or (string.find(k,'variable')~=nil) or (string.sub(k,1,4)=='time') or (string.sub(k,1,8)=='security')) then if type(v)=="string" then print(name.."['"..k.."'] = '"..v.."'") end if type(v)=="number" then print(name.."['"..k.."'] = "..v) end if type(v)=="boolean" then print(name.."['"..k.."'] = "..tostring(v)) end if type(v)=="table" then LogVariables(v,depth+1,k); end end end end -- call with this command LogVariables(_G,0,''); </syntaxhighlight> == Date and Time == === Funtion to calculate the time difference === <syntaxhighlight lang="lua"> function timedifference(s) y, m, d, H, M, S = timestamp:match("(%d+)-(%d+)-(%d+) (%d+):(%d+):(%d+)") difference = os.difftime(os.time(), os.time{year=y, month=m, day=d, hour=H, min=M, sec=S}) return difference end</syntaxhighlight> === Time of day === Check if it is daytime or nighttime Example: <syntaxhighlight lang="lua"> if (timeofday['Daytime']) then ... or if (timeofday['Nighttime']) then ... </syntaxhighlight> == Devices == [[Category:Domoticz]] [[Category:手册]] [[Category:设置]] [[Category:脚本]] [[Category:Lua]]
返回
LUA命令
。
开关有限宽度模式