Page 1 of 1
Re: lua script not working anymore after update
Posted: Thursday 07 November 2019 9:26
by waaren
sander815 wrote: Thursday 07 November 2019 9:13
Are there changes in lua scripting?
Yes.
Please state your domoticz version, os, any recent changes (if any) and include relevant loglines. That might help in answering you in a more useful way.
Re: lua script not working anymore after update
Posted: Thursday 07 November 2019 9:41
by waaren
sander815 wrote: Thursday 07 November 2019 9:34
os: Raspbian GNU/Linux 9
Linux rpi3 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux
Version: 4.11468
i only did apt-get update/upgrade, and upgraded to latest beta
No changes to the lua scripts
A couple of days ago the embedded Lua version has been updated from Lua 5.2 to Lua 5.3 (announced
here ).
What was the domoticz version before the update to the latest beta ?
Can you please include loglines that show the results of the script print commands ?
Re: lua script not working anymore after update
Posted: Thursday 07 November 2019 12:14
by waaren
sander815 wrote: Thursday 07 November 2019 10:21
when i initiate a switch command, i get no errors:
If you can try with this dzVents script you might see a somewhat useful message pointing to what goes wrong.
When not yet familiar with dzVents please start with reading
Get started Before implementing (~ 5 minutes). Special attention please for "In Domoticz go to Setup > Settings > Other and in the section EventSystem make sure the checkbox 'dzVents disabled' is not checked. Also make sure that in the Security section in the settings you allow 127.0.0.1 to not need a password. dzVents uses that port to send certain commands to Domoticz. Finally make sure you have set your current location in Setup > Settings > System > Location, otherwise there is no way to determine nighttime/daytime state."
Code: Select all
local DomDevice = 'Keukenlampboven'
return
{
on = { devices = { DomDevice }},
logging = { level = domoticz.LOG_DEBUG, marker = DomDevice },
execute = function(dz, item)
local function composeCommand(targetValue)
return ('echo Fadetimer=5000,LED2_Target=' .. targetValue .. ' | nc -vw 1 192.168.1.230 43333 '.. ' ' )
end
local function osCommand(cmd)
dz.log('Executing Command: ' .. cmd,dz.LOG_DEBUG)
local fileHandle = assert(io.popen(cmd .. ' 2>&1 || echo ::ERROR::', 'r'))
local commandOutput = assert(fileHandle:read('*a'))
local returnTable = {fileHandle:close()}
if commandOutput:find '::ERROR::' then -- something went wrong
dz.log('Error ==>> ' .. tostring(commandOutput:match('^(.*)%s+::ERROR::') or ' ... but no error message ' ) ,dz.LOG_DEBUG)
else -- all is fine!!
dz.log('ReturnCode: ' .. returnTable[3] .. '\ncommandOutput:\n' .. commandOutput, dz.LOG_DEBUG)
end
return commandOutput,returnTable[3] -- rc[3] contains returnCode
end
if item.state == 'Off' then
dz.log('Turning off ' .. DomDevice, dz.LOG_DEBUG)
osCommand(composeCommand(0))
else
local CalcValue = math.floor(item.level * 33)
dz.log('Value received from Domoticz was ' .. item.level, dz.LOG_DEBUG)
dz.log('Dimming ' .. DomDevice .. ' to ' .. CalcValue,dz.LOG_DEBUG)
osCommand(composeCommand(CalcValue))
end
end
}