[fsync] make sure fsync works with null voltage/current/constant entries in the uci

This commit is contained in:
Bart Van Der Meerssche 2011-04-23 00:00:32 +02:00
parent 65d3b09bb4
commit e53d1d384f
1 changed files with 3 additions and 3 deletions

View File

@ -209,12 +209,12 @@ for i = 1, MAX_SENSORS do
cmd = string.format(SET_METERCONST, toc(i), 0)
elseif flukso[tostring(i)]['class'] == 'analog' then
local voltage = tonumber(flukso[tostring(i)].voltage)
local current = tonumber(flukso[tostring(i)].current)
local voltage = tonumber(flukso[tostring(i)].voltage or "0")
local current = tonumber(flukso[tostring(i)].current or "0")
cmd = string.format(SET_METERCONST, toc(i), math.floor(METERCONST_FACTOR * voltage * current))
elseif flukso[tostring(i)]['class'] == 'pulse'then
local meterconst = tonumber(flukso[tostring(i)].constant)
local meterconst = tonumber(flukso[tostring(i)].constant or "0")
cmd = string.format(SET_METERCONST, toc(i), meterconst)
else
cmd = string.format(SET_METERCONST, toc(i), 0)