Im trying to get the gasmeter to count but I'm getting the following error:
pi@raspberrypi ~ $ sudo /home/pi/domoticz/scripts/lua/script_device_gaspuls.lua
: not foundmoticz/scripts/lua/script_device_gaspuls.lua: 1: /home/pi/domoticz/scripts/lua/script_device_gaspuls.lua: 15287.669
/home/pi/domoticz/scripts/lua/script_device_gaspuls.lua: 1: /home/pi/domoticz/scripts/lua/script_device_gaspuls.lua: --: not found
: not foundmoticz/scripts/lua/script_device_gaspuls.lua: 2: /home/pi/domoticz/scripts/lua/script_device_gaspuls.lua:
/home/pi/domoticz/scripts/lua/script_device_gaspuls.lua: 3: /home/pi/domoticz/scripts/lua/script_device_gaspuls.lua: commandArray: not found
: not foundmoticz/scripts/lua/script_device_gaspuls.lua: 4: /home/pi/domoticz/scripts/lua/script_device_gaspuls.lua:
/home/pi/domoticz/scripts/lua/script_device_gaspuls.lua: 5: local: not in a function
my script_device_gaspuls.lua:
local virtualcounter_idx = "72" = IDX virtual gasmeter
local switchName = "gaspuls" = KaKu amst 606
Code: Select all
--|15287.669
commandArray = {}
local thisfilename = "/home/pi/domoticz/scripts/lua/script_device_gaspuls.lua"
local virtualcounter_idx = "72"
local switchName = "gaspuls"
if devicechanged[switchName] == 'On' then
-- Open this file and read in the first line
file = io.open(thisfilename, "rb")
sContents = file:read("*l")
file:close()
-- Parse and update the countvalue
foo, snumber = sContents:match("([^,]+)|([^,]+)")
local countvalue = snumber + 0.010
local newline = foo .. "|" .. string.format("%.3f", tostring(countvalue))
-- Update virtual counter device
ts = virtualcounter_idx .. "|0|" .. string.format("%.3f", tostring(countvalue))
commandArray['UpdateDevice'] = ts
-- Write back new counter value
local file = io.open(thisfilename, "r+")
file:write(newline)
file:close()
end
return commandArray
Has anyone a solution for me?