Using the average of a trend log value in a script - 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: Using the average of a trend log value in a script (/showthread.php?tid=5617) |
Using the average of a trend log value in a script - dnavarro - 15.09.2024 Hello, Thank you everyone for all the help I already got reading other posts :-) I'm new to LogicMachine. I have a KNX system with a weather station which reads the luminosity outside the house, I want to use that value to determine if it's sunny or cloudy outside, but to avoid errors due to shadows or small clouds covering the sun for few minutes, I would like to use, instead of the point value, the average of the last 30 minutes. Is it possible to use the values stored from the trends to achieve that? otherwise, any other idea on how to get an accurate reading of the su/clouds to use for opening/closing the awnings? RE: Using the average of a trend log value in a script - Daniel - 16.09.2024 https://forum.logicmachine.net/showthread.php?tid=291&pid=3217#pid3217 RE: Using the average of a trend log value in a script - dnavarro - 16.09.2024 (16.09.2024, 07:29)Daniel Wrote: https://forum.logicmachine.net/showthread.php?tid=291&pid=3217#pid3217 Thanks for your reply, I indeed saw that post, but I wanted to use the historical data that I already have stored in the trends log for that specific item, is that not possible? Thanks! RE: Using the average of a trend log value in a script - Daniel - 16.09.2024 You can use this: https://kb.logicmachine.net/libraries/trends/ RE: Using the average of a trend log value in a script - admin - 16.09.2024 Trends keep 1 hour of object values sampled every minute which you can use. This won't be a true average though because any changes between sampling times are lost. This example will fetch values from the past 30 minutes and calculate the average value. Code: require('trends') RE: Using the average of a trend log value in a script - dnavarro - 16.09.2024 Thanks again for pointing me on the right direction, here is my code in case it's useful for someone else: Code: require('trends') |