07.01.2017, 09:59
Hi,
I have also applied this with temperatures too, the following will average Celsius temps and then convert it to Fahrenheit.
Thanks,
Roger
I have also applied this with temperatures too, the following will average Celsius temps and then convert it to Fahrenheit.
Code:
-- Temperature AVERAGE value
calc['tempavg'] = function(group)
local result, count, value = 0, 0
for _, address in ipairs(group.objects) do
value = values[ address ]
-- number must be in [0..100] range
if type(value) == 'number' then
result = result + value
count = count + 1
end
end
if count > 0 then
result = result / count
local fahren= math.floor(((result * 9 / 5 + 32) * 10^2) + 0.5) / (10^2)
grp.checkupdate(group.output, fahren)
end
end
Thanks,
Roger