24h Temperature average - 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: 24h Temperature average (/showthread.php?tid=4244) |
24h Temperature average - kropfm - 17.09.2022 Hello there I've been trying to find a good solution to determine the average temperature of the day. My idea was it to trigger a script whenever a new value is being sent. I would then add the value to a variable and divide it by the number of values. Shortly befor midnight I would then store the value and clear counter and sum. I also looked a the log option, but I get the impression that I have very few log entries of any group address that I log. How could I achieve that? If you can point me to a similar code sample that be very helpful. Thanks a lot! Cheers! Martin RE: 24h Temperature average - pioneersteffen - 18.09.2022 Hi Martin, I made the moving average in my solution as following: 1. Create object / group address for the average value (example: 49/0/1) 2. Create time triggered script with 5min cycle time 3. Use the following code inside the script and adjust the value group address: Code: average=grp.getvalue('49/0/1') I hope this is working for you! Best Regards Steffen RE: 24h Temperature average - Daniel - 19.09.2022 https://forum.logicmachine.net/showthread.php?tid=2696&pid=17347#pid17347 RE: 24h Temperature average - admin - 19.09.2022 Another option is to use storage. 1. Event script to accumulate the values: Code: value = event.getvalue() 2. Scheduled script to calculate the average and reset the accumulated values: Code: key = 'average' RE: 24h Temperature average - kropfm - 21.09.2022 (18.09.2022, 18:23)Hi SteffenThanks a lot, this looks like a neat solution. I shall try it this weekend and report.Cheers!Martinpioneersteffen Wrote: Hi Martin, RE: 24h Temperature average - kropfm - 22.09.2022 (19.09.2022, 07:28)Daniel Wrote: https://forum.logicmachine.net/showthread.php?tid=2696&pid=17347#pid17347 thanks Daniel for the pointer. (19.09.2022, 08:15)admin Wrote: Another option is to use storage. thank you very much, I shall try this too. |