Page 1 of 1

Switch status in time script

Posted: Saturday 17 September 2022 10:29
by pkelderman
Hello, I am a newbe in lua. I have a time script in which I want to ask the status of a dummy-switch.
As a test I tried:

if (otherdevices('Alarm_Aan_Uit') == 'On') then
print('Aan')
else
print('Uit')
end
In the log I find:
2022-09-17 10:28:00.488 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_PIRs.lua: /home/pi/domoticz/scripts/lua/script_time_PIRs.lua:37: attempt to call a table value (global 'otherdevices')
What is my error?

Re: Switch status in time script

Posted: Saturday 17 September 2022 10:36
by pkelderman
I found my own error! Use [] instead of (). Does somebody know a complet description of lua syntax and domoticz functions?

Re: Switch status in time script

Posted: Saturday 17 September 2022 10:56
by psubiaco
LUA is a standard scripting language: you can find manuals in the web, https://www.lua.org

To write scripts for Domoticz, you can find several example in the Domoticz wiki https://www.domoticz.com/wiki and github: you can find many scripts at https://github.com/CreasolTech/domoticz_lua_scripts