LogicMachine Forum
Object On Time - Printable Version

+- LogicMachine 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: Object On Time (/showthread.php?tid=6503)



Object On Time - sjfp - 09.07.2026

Hi, looking for any possible examples or suggestion on how to implement a monitor script which will record how long an object is switched ON.
At present we have 40 objects (using a tag name of event_log) so we can define which objects to monitor.
We need to calculate usage by daily, weekly, monthly and year for each individual object. Was thinking of creating a .LP file to use to email data table to client.

Any help would be much appreciated.


RE: Object On Time - Erwin van der Zwart - 09.07.2026

You can use updatetime for this..

grp.find('1/1/1').updatetime wil give you the unix timestamp that you can compare with os.time() to calculate the seconds the object has this value.

You can use storage to store this value when using event based scripts so you can fetch the value from storage from last event and then store new timestamp again.

You mentioned period usage, why not using a trend on a value and use trend.fetchone to get the usage over a set period?

https://kb.logicmachine.net/libraries/trends/


RE: Object On Time - admin - 17.07.2026

You can use trends logs for this if the object does not change very often since the current value is sampled once per minute.

Assign a trend to a binary object, use Absolute value / Average mode / 1 hour resolution / 3 decimal places. The resulting trend values will show how much of time selected time period the object was in ON state (for example 0.5 = 30 minutes per hour).