Logic Machine Forum
Average temperatur - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Average temperatur (/showthread.php?tid=1423)



Average temperatur - Tokatubs - 31.05.2018

Hi 

I have a big room with 3 thermostats. Could there the some logic to compare in the logic module to compare the three temperatures to get an average temp. Then use this to control the room?


RE: Average temperatur - Erwin van der Zwart - 31.05.2018

Hi,

Try this:
Code:
T1 = grp.getvalue('1/1/1')
T2 = grp.getvalue('1/1/2')
T3 = grp.getvalue('1/1/3')
AV = math.round((T1 + T2 + T3) / 3, 2)
grp.write('1/1/4', AV)
BR,

Erwin


RE: Average temperatur - equalizer - 01.06.2018

Is rounding needed?  I normally just sent the value to the knx driver and let it deal with the formatting.  (Though thinking about it I have not checked if its rounding or just chopping off the decimal places...)


RE: Average temperatur - Tokatubs - 01.06.2018

Scripts is hard learning for me. So i try but really not my best side. 

Ok so i put a new script in event based. Then i pushed the run script button on the bottom. 

But then it flooded my knx group monitor writing the value every milli second. 
What did i do wrong?


RE: Average temperatur - Erwin van der Zwart - 02.06.2018

Hi,

You probably have the event on the output, this will retrigger the event every time the output is written.

For the correct avarage like sample above you need to put a tag on the 3 input values and set the event script to the same tag. Make sure the output is NOT tagged like the inputs.

BR,

Erwin


RE: Average temperatur - Tokatubs - 02.06.2018

(02.06.2018, 07:23)Erwin van der Zwart Wrote: Hi,

You probably have the event on the output, this will retrigger the event every time the output is written.

For the correct avarage like sample above you need to put a tag on the 3 input values and set the event script to the same tag. Make sure the output is NOT tagged like the inputs.

BR,

Erwin
Yes that was the case. Thanks alot. The scripting is a whole New game for see. So much to learn, and dont really dont know where to start. 

Thanks again.


RE: Average temperatur - Erwin van der Zwart - 02.06.2018

Hi,

If script is to hard for you at the moment you can always use the FBeditor app, there should be a average graphic block.

Basic functions are fine to do with it..

BR,

Erwin


RE: Average temperatur - Tokatubs - 02.06.2018

(02.06.2018, 17:00)Erwin van der Zwart Wrote: Hi,

If script is to hard for you at the moment you can always use the FBeditor app, there should be a average graphic block.

Basic functions are fine to do with it..

BR,

Erwin

I have used the FBeditor for functions. And looked but could not find something to measure analog values. But i will have another look. But thanks for all the help..