====Energy Use Example==== ===Our Goal=== The goal is to have daily summaries showing how much energy we consumed during the day. ===Plan=== To do this, we will need to identify the place(s) where energy use can be measured, then create totals from that data. Using our [[bakery|https://demo.optrix.com.au/s/default]] demo, we have two places we can measure. * The [[https://demo.optrix.com.au/s/default/dashboard/140|Incomer Power Meter]] for electrical power usage, and * The [[https://demo.optrix.com.au/s/default/dashboard/112|Main Oven Gas Flowmeter]] for gas usage. ===Step 1: Get Strict Days=== This step gets the last 24 hours up to 6:00AM in the current day. If the user chooses to run this analytic over many days, it will be broken up into 24-hour batches. { "type": "get_day", "upto": "06:00", "comment": "Get The Full Day Span" } ===Step 2: Get the Gas Usage Values=== For each day, we need to get the history of gas usage. { "type": "get_query", "points": ["Main Oven Gas Flowmeter.Flow - Natural Gas"], "comment": "Get gas flows" }, ===Step 3: Calculate the Total=== We use the **ValueSummary** layer to take our rate and convert it into a total across the day. In this case, our raw measurement is in //normal meters cubed per minute//, and we'd like the final summary in cubic meters. So the time factor is '60' (sixty-seconds per minute) and the multiplier is '1' (no change in units) { "type": "valuesummary", "rate": "Main Oven Gas Flowmeter.Flow - Natural Gas", "values": ["total"], "named": ["Total Gas Consumed"], "timebase": 60, "multiplier": 1 }, { "type": "reset", "comment": "Clear" } ===Step 4: Repeat for Power=== Now we do the same thing again, but for power. However in this case, we need to correct the units. We have a live reading of the number of amps being drawn by our equipment. To turn that into actual power consumption, we need to convert into //killowatt hours//. If we assume a constant, reliable 240VAC supply, we can do this by applying a multiplier of 0.24 (1A over 1 hour = 240W, or 0.24kW). { "type": "get_query", "points": ["Incomer Power Meter.Current"], "comment": "Get power flows" }, { "type": "valuesummary", "rate": "Incomer Power Meter.Current", "values": ["total"], "named": ["Total kW-Hours"], "timebase": 3600, "multiplier": 0.24 } ===Full JSON=== Below is the complete configuration for this capture on the Bakery. { "name": "Daily Energy Usage", "uniqueid": "{Date}", "keys": ["Date","Total Gas Consumed","Total Amp-Hours"], "strings": ["Date"], "date": "StartTime", "steps": [ { "type": "get_day", "upto": "06:00", "comment": "Get The Full Day Span" }, { "type": "flatten", "method": "first", "comment": "Record Day Details" }, { "type": "get_query", "points": ["Main Oven Gas Flowmeter.Flow - Natural Gas"], "comment": "Get gas flows" }, { "type": "valuesummary", "rate": "Main Oven Gas Flowmeter.Flow - Natural Gas", "values": ["total"], "named": ["Total Gas Consumed"], "timebase": 60, "multiplier": 0.0001 }, { "type": "reset", "comment": "Clear" }, { "type": "get_query", "points": ["Incomer Power Meter.Current"], "comment": "Get Power Usage" }, { "type": "valuesummary", "rate": "Incomer Power Meter.Current", "values": ["total"], "named": ["Total Amp-Hours"], "timebase": 3600, "multiplier": 1 } ] }