Re: lua script not working anymore after update
Posted: Thursday 07 November 2019 9:26
Open source Home Automation System
https://forum.domoticz.com/
A couple of days ago the embedded Lua version has been updated from Lua 5.2 to Lua 5.3 (announced here ).
If you can try with this dzVents script you might see a somewhat useful message pointing to what goes wrong.
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
}