Script Data Source
-
I am trying to get the kWh consumption of a point from the past SUN, MON, .... SAT. How would I do this in the Scripting data source?
Thx.
-
Can you explain a bit more what the raw data is? Is the data an incrementing register of kWh? I would probably do this with a Meta Data Point rather than a Scripting Data Source.
Do you want to calculate a daily total?
-
Hi Joel. Yes it is an incrementing kWh register. Therefore I would need the hourly consumption for e.g. Sunday 12am 1am .... and so on Those value will then be calculated against a hourly maximum and rescaled to give a value between 0 - 1 that will then be bound to alpha of a solid filled block in DGLux to represent the energy uses in colour intensity for each hour. Does this make sense. Something similar to the attached image.
-
I see, this is a pretty cool idea.
This article in the wiki should help: http://infiniteautomation.com/wiki/doku.php?id=automation:script_examples
If you run this Meta Script at the end of each hour it will calculate your hourly kWh:
return p1.value - p1.ago(HOUR)
I'm sure how you will create this in DGLux but I think the logic to determine the color for each hour would be better in DGLux.
The other thing you might consider is to use our API and do it in pure JavaScript which would be a bit more flexible