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.

arithmetic on local - error
#1
I'm trying to subtract numbers from a 4 Byte Signed Int but keep getting this error.
Can't figure out how to do the calculation without getting errors.

I have 2 meters in series, so I want to down count Wh that have been measured twice.


Quote:Energimätare Timme 16.11.2022 20:09:30
User script:14: attempt to perform arithmetic on local 'strHuset1' (a nil value)
stack traceback:


Code:
-- Begär avläsning från statistikmätaren för Bergvärmen
grp.read('7/1/9')

-- Vänta 5 sekunder på resultat från mätaren
os.sleep(5)

-- Läs in värdet och omvandla kWh till Wh på Bergvärmemätningen
local strBVP = grp.getvalue('7/1/9')/1000

-- Läs in värdet från Husförbrukningen i Wh
local res1, strHuset1 = grp.getvalue('7/0/22')

-- Räkna av Bergvärmen från husförbrukningen
local res2, strHuset2 = strHuset1 - strBVP
log(res1, res2)

grp.write('7/4/1', strBVP)
grp.write('7/0/23', strHuset1)
grp.write('7/0/24', strHuset2)
grp.write('7/4/3', true)
os.sleep(20)
grp.write('7/4/3', false)
Reply


Messages In This Thread
arithmetic on local - error - by sx3 - 16.11.2022, 19:13
RE: arithmetic on local - error - by admin - 17.11.2022, 07:04
RE: arithmetic on local - error - by sx3 - 17.11.2022, 07:15
RE: arithmetic on local - error - by admin - 17.11.2022, 09:08

Forum Jump: