Logic Machine Forum
Trends average by Schedule (month,year) - 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: Trends average by Schedule (month,year) (/showthread.php?tid=3296)



Trends average by Schedule (month,year) - batistacaceres - 12.04.2021

Hi,

Is there anyway to trend data excluding some hour of the day?

For example, if in a day I don´t write data in the object at night, I don´t want to include on daily, monthly, yearly... average

In this average, I only want to include data from 7:00 to 20:00.

Thanks


RE: Trends average by Schedule (month,year) - admin - 12.04.2021

Create a virtual object with the same data type as the object you want to log. Then attach an event script to the source object that will write the real value between 7:00 and 19:59, and 0 otherwise. Trend log must be attached to the virtual object.

Event script, change virtual object address (32/1/1) as needed:
Code:
hour = os.date('*t').hour
if hour >= 7 and hour < 20 then
  value = event.getvalue()
else
  value = 0
end

grp.checkupdate('32/1/1', value)