User Tools

Site Tools


wiki:diff

DIFF() Function

The DIFF() function can be used in a variety of ways to get the difference (end-start) between a value at two timestamps. This is typically used for incrementing counters such as kWh or total liters.

Usage:

DIFF(variable, options, [days],[minutes],[min],[max]) - see below for description.

Parameters:

variable - Variable name to use

options - Type of diff (see below)

days - optional number of days to lookup before selected day

mins - optional number of minutes to offset by

min - minimum value, will result in 0 if it is below this value

max - maximum value, will result in 0 if it is above this value

Generic Variables (per device type)

DIFF('INC1_AE', 5)

Get the difference for the selected period

Device - Specific Variables

For device specific variables use a . to separate the device name:

VALUE('My Device.My Value',1)

Get the difference between current value and start of today for the variable 'My Value' in the device 'My Device'

Option Parameters

The second parameter, [options] is a number and can be any of the following

0 latest value (Default)
1 DAY - Difference between start of day and latest value
2 WEEK - Difference between start of week and latest value
3 MONTH - Difference between start of month and latest value
4 YEAR - Difference between start of year and latest value
5 PERIOD - Difference between start and end of selected date range
6 AT_START_DATE - value at the start of the selected date range
7 AT_END_DATE - value at the end of the selected date range
8 PERIOD_CUMULATIVE - value between start of period and range element (in a graph)
9 FULL_MONTH - Difference between 1st and last day of month for selected date

The third parameter is an optional one and lets you specify a number days. This is subtracted from the currently selected period to allow you to graph historic data alongside current data.

Example

Show a cumulative value for data within a period:

(DIFF('delta0_kwh',8)

The graph for cumulative values since period start looks like this:

(DIFF('delta0_kwh',5)

The graph for period for the same variable looks like this:

Get the solar generation for one year ago (365 days):

(DIFF('inverter1_AC_Total_kWh',0,365)

wiki/diff.txt · Last modified: 2024/10/01 04:39 by admin