Skip to main content
Version: V2 (Ignition 8.1)

system.mes.meter.calculateMeterSummaryByTimeInterval

Description

Calculates meter summaries bucketed by a specified time interval within a date range with optional filters. Returns a list of summary objects, one per interval bucket, each containing the same comprehensive metrics as calculateMeterSummary.

Permissions

This method requires the METERING.READ.CALCULATE permission.

Syntax

system.mes.meter.calculateMeterSummaryByTimeInterval(startDate, endDate, interval, intervalTimeUnits, equipmentIdOrPath=None, locationIdOrPath=None, meterTypeIdOrName=None, meterIdOrName=None, statuses=None, targetUsageUomIdOrName=None, targetCostUomIdOrName=None)

Parameters

ParameterTypeNullableDescription
startDateDateFalseStart date (inclusive) as a Date object or milliseconds since epoch.
endDateDateFalseEnd date (inclusive) as a Date object or milliseconds since epoch.
intervalIntegerFalseDuration of each time bucket. Must be greater than 0.
intervalTimeUnitsStringFalseTime unit for the interval. One of: SECONDS, MINUTES, HOURS, DAYS, WEEKS, MONTHS, YEARS.
equipmentIdOrPathStringTrueFilter by equipment ID or path.
locationIdOrPathStringTrueFilter by location ID or path.
meterTypeIdOrNameStringTrueFilter by meter type ID or name.
meterIdOrNameStringTrueFilter by meter record ID or name.
statusesList<String>TrueFilter by status values (e.g., ['RUNNING', 'COMPLETED']).
targetUsageUomIdOrNameStringTrueTarget unit of measure ID or name for usage conversion. If omitted, uses the most frequent unit from matched records.
targetCostUomIdOrNameStringTrueTarget unit of measure ID or name for cost conversion. If omitted, uses the most frequent unit from matched records.

Returns

Returns a list of JSON objects, one per time interval bucket. Each object has the following properties:

NameTypeDescription
startDateInstantStart date (inclusive) of this interval bucket.
endDateInstantEnd date (inclusive) of this interval bucket.
totalUsageDoubleTotal usage accumulated during this interval.
totalCostDoubleTotal cost accumulated during this interval.
averageCostPerUsageDoubleAverage cost per usage unit for this interval.
usageUnitOfMeasureNameStringName of the usage unit of measure.
usageUnitOfMeasureSymbolStringSymbol of the usage unit of measure.
costUnitOfMeasureNameStringName of the cost unit of measure.
costUnitOfMeasureSymbolStringSymbol of the cost unit of measure.
recordCountIntegerNumber of Meter Records included in this interval.
totalDurationSecDoubleTotal duration across all records in this interval in seconds.
averageUsagePerSecondDoubleAverage usage rate per second for this interval.
averageCostPerSecondDoubleAverage cost rate per second for this interval.
peakUsagePerSecondDoublePeak (maximum) usage rate per second across records in this interval.
minUsagePerSecondDoubleMinimum usage rate per second across records in this interval.
peakCostPerSecondDoublePeak (maximum) cost rate per second across records in this interval.
minCostPerSecondDoubleMinimum cost rate per second across records in this interval.
peakCostPerUsageDoublePeak cost per usage unit across records in this interval.
minCostPerUsageDoubleMinimum cost per usage unit across records in this interval.

Code Examples

# Calculate daily electricity usage summaries for the past 7 days
startDate = system.date.addDays(system.date.now(), -7)
endDate = system.date.now()

summaries = system.mes.meter.calculateMeterSummaryByTimeInterval(
startDate,
endDate,
1,
'DAYS',
equipmentIdOrPath='Enterprise/Site/Line1',
meterTypeIdOrName='Electricity'
)

# Output the daily usage for each day
for dailySummary in summaries:
print("Date:", dailySummary['startDate'], "Usage:", dailySummary['totalUsage'], dailySummary['usageUnitOfMeasureSymbol'])