User Tools

Site Tools


wiki:firstnz

FIRSTNZ() Function

The FIRSTNZ() function (first non-zero) can be used to get the first value and timestamp for a variable above zero or a given threshold - it returns a human readable time, a value, or a combination of the two.

Usage:

FIRSTNZ(variable, options, type, threshold_value)

variable - the variable name to check

options - see below

type - return type: 0 = value, 1 = time of first match, 2 = value + time of first match

val - optional - threshold value to compare against (default is 0)

Generic Variables (per device type)

FIRSTNZ('genset_on',1,1)

Get the first time that the genset_on variable was set today

FIRSTNZ('inverter_state',1,0,3)

Get the get the first inverter state that was above 3 today

Device - Specific Variables

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

FIRSTNZ('My Device.My Value',1,2)

Option Parameters

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

0 Returns No Change
1 DAY - First time the variable changed during the day
2 WEEK - First time the variable changed during the week
3 MONTH - First time the variable changed during the month
4 YEAR - First time the variable changed during the current year
5 PERIOD - First time the variable changed during the selected range
6 SLICE - First time the variable changed during the slice in the range (i.e. in a graph segment)

Example

Get the first time the variable changed this week

FIRSTNZ('delta0_w',1,1,1500)

Returns the first time in the day that the value of delta0_w was greater than 1500

wiki/firstnz.txt · Last modified: 2021/02/02 08:15 by admin