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.

from watt to kilowatt
#1
I have done this scritp to change the value from watt/h to kilowatt/h. But it gives me always 0. Why??

-------------------------------------------------------------------------------
function kilowatt()
 
    local value = event.getvalue('32/2/16')
   
 
    if value then
     
        local new_value = value * 0.001
       
        return new_value
    else
     
   
    end
end

local valor = kilowatt()

 
    grp.write('32/2/16', valor)
Reply
#2
You need to use a different object/group address to store the kW value. Otherwise your script is an infinite loop which will overload LM.

Simplified version of this script (32/2/17 must not be the triggering object):
Code:
kw = event.getvalue() / 1000
grp.checkupdate('32/2/17', kw)
Reply


Forum Jump: