After upgrading to V3.8153 I have the folowing error in my logfile upon calling a LUA script: bad argument #1 to 'read' (invalid format)
Code: Select all
--|1502624.00
print ('Script Water Started')
commandArray = {}
local thisfilename = "/home/pi/dev-domoticz/scripts/lua/script_device_water.lua"
local virtualcounter_idx = "53"
local switchName = "water"
if devicechanged [switchName] == 'On' then
-- Open this file and read the first line
file = io.open (thisfilename, "rb")
sContents = file:read ("*1")
file:close()
-- Parse and update the countvalue
foo,snumber = sContents:match("([^,]+)|([^,]+)")
local countvalue = snumber + 0,50
local newline = foo .. "|" .. string.format("%.2f", tostring (countvalue))
-- Update virtual counter device
ts = virtualcounter_idx .. "|0|" .. string.format("%2.f",tostring(countvalue))
commandArray['UpdateDevice'] = ts
-- Write back new counter value
local file = io.open(thisfilename, "r+")
file:write(newline)
file:close()
end
return commandArray
Any insights as I don't seem to find this specific error on the board or using Google.
Thx
P.