09.08.2022, 07:44
Hi.
Is it possible to change this Unit/Suffix automatic it the value is over a specific number?
I run this script in resident and have it to calculate the number thats presented, but then I also need to change Unit/Suffix from kWh to MWh so theres no confusion : )
Is this possible to implement in my script or can´t this be done?
Is it possible to change this Unit/Suffix automatic it the value is over a specific number?
I run this script in resident and have it to calculate the number thats presented, but then I also need to change Unit/Suffix from kWh to MWh so theres no confusion : )
Is this possible to implement in my script or can´t this be done?
Code:
-- Total power year
r1, r2, r3, r4 = mb:readregisters(505, 4)
if r1 then
value = r1 * 0x1000000000000 + r2 * 0x100000000 + r3 * 0x10000 + r4
currentvalue = grp.getvalue('32/1/54')
if tonumber(currentvalue) ~= value then
if value >999
then
grp.update('32/1/54', value /1000000)
else
grp.update('32/1/54', value /1000)
end
end
end