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.

Advice on hanging Resident script (suspect storage get/set)
#1
Hi, i'm experiencing some kind of hang/blocking/locking when this script runs for a few days.
 
The script runs as a Resident script every minute, but suddenly it stops. I try to disable, re- enable but without any success. 
Then, when I alter the storage key ('3_3_15_vent_effect') to e.g. '3_3_15_vent_effect_1' it runs fine for some time (days?).
 
Should I safeguard the storage get/set in some way? I'm I missing something obvious here?
 
Code:
1234567891011121314151617181920
deltaThreshold = 0.015 t1 = grp.getvalue('3/3/10') t2 = grp.getvalue('3/3/11') t3 = grp.getvalue('3/3/14') -- Calc. effect effect = (t1 - t3) / (t2 - t3) prev_effect = storage.get('3_3_15_vent_effect', 0) effectDelta = math.abs(prev_effect - effect) -- Write to KNX buss if Delta > Treshold if effectDelta > deltaThreshold then  grp.write('3/3/15', effect)    -- Store Calculated effect  storage.set('3_3_15_vent_effect', effect)    log("New reading - Effect prev.=" .. prev_effect .. " New = " .. effect) end

About the script: Calculate the effect of a heat recovery unit. Input values are collected from ModBus interface on LM (no need to do a grp.read()). I don't want to flood the KNX buss by writing every calculation, therefore the delta calculation. 

Alternative approaches are welcome...


_
Ole A.
Reply
#2
You don't need storage in a resident script like this. All variables will keep their values after each call, but will be nil on first script run, so you have to check for that. Sending a telegram once a minute is not a problem. You should use grp.update instead of grp.write if you don't need this value on KNX/TP bus.
Reply
#3
Thank you for clarifying. Didn't realize variables were persisted at this level. 
 
Needs the values on the bus, and as we know, "he" is a grumpy ~100year old man you shouldn’t nag too often Wink 

_
Ole A.
Reply
#4
I did this another way, I also use the modbus to collect from Systemair unit as well as my 1 wire sensors in the hc unit to collect values.
I have made a script that runs on event change. That means if one of the three values are updated then the script runs. Works as a charmSmile results last 24 hours can be viewed on www.passivpluss.no Smile
Reply


Forum Jump: