• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    Script Data Source

    User help
    2
    4
    2.1k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      alexcclarke
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • JoelHaggarJ
        JoelHaggar
        last edited by

        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?

        1 Reply Last reply Reply Quote 0
        • A
          alexcclarke
          last edited by

          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. Untitled.png

          1 Reply Last reply Reply Quote 0
          • JoelHaggarJ
            JoelHaggar
            last edited by

            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

            1 Reply Last reply Reply Quote 0
            • First post
              Last post