Build Hash: aa52bc9
Compile Date: 2018-03-25 13:47:29
dzVents Version: 2.4.1
Python Version: 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609]
Need some advice on how to tune this script or other settings in Domoticz so I can get the data I want

Short on the setup ...
Watermeter with a pulse output ( 1 P pr 10 L )
Fibaro FGBS-001 Universal Binary Sensor, for the input ..
Fresh Ubuntu server install on a ASUS J1800I-C motherboard...
Been running Domoticz on a PI since 2015 before ...
Scrip below are basically the same as posted http://www.domoticz.com/forum/viewtopic ... oor#p22721, was simple enugh for me to understand

It does work, sort of, but I can't get the numbers I want, as you can see it says 1000L, and not ?? more like 100 or 250 ...
The 1,34m3 are probably correct...
As for the log ... nothing shows up

The divider inside setup are sett at 1 ... I have tried other settings, but then the m3 are way off ...
Probably just a simple typo somwhere, but are not good at scrips

Arne Kjetil
Code: Select all
--|1.340
commandArray = {}
local thisfilename = "/home/domoticz/domoticz/scripts/lua/script_device_Vann_forbruk.lua"
local virtualcounter_idx = "494"
local switchName = "Vann_forbruk"
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.01
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
