This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

[solved] Most efficient way to get sum of all light states?
#8
Hi,

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
Reply


Messages In This Thread
RE: Most efficient way to get sum of all light states? - by rocfusion - 07.01.2017, 09:59

Forum Jump: