Phi function reference

IoT functions for getting node IDs of the hierarchy, and data field values

The following Assetwolf-specific functions are available in Phi:

  • getAllChildIds([string schema[, integer nodeId]])

    Returns array

    If given no parameters, this function returns all of the child node IDs of the current asset or data pool, at any number of levels below.

    You can optionally filter by a specific schema, specified by the parameter schema.

    You may also pass in a node ID, specified by the parameter nodeId.

    (Tip: you may obtain IDs from the functions getParentNodeId(), getImmediateChildIds(), getAllChildIds(), getAllChildAssetIds() or getAllChildDataPoolIds().)

  • getImmediateChildIds([string schema[, integer nodeId]])

    Returns array

    This gives you all of the immediate children of the current asset or data pool, i.e. at one level below.

    You can optionally filter by a specific schema.

    This checks from the current asset or data pool by default, but you may pass in an id obtained from either the getParentNodeId(), getImmediateChildIds(), getAllChildIds(), getAllChildAssetIds() or getAllChildDataPoolIds() function to override this.

  • getAllChildAssetIds([integer nodeId])

    Returns array

    If given no parameters, this function returns all of the IDs of assets (as opposed to data pools) under the current data pool (at any level below).

    You may optionally pass the ID of a different data pool, specified by the parameter nodeId, in which case the function with find the IDs of assets under that data pool.

  • getAllChildDataPoolIds([integer nodeId])

    Returns array

    If given no parameters, this function returns all of the IDs of data pools (as opposed to assets) under the current data pool.

    You may optionally pass the ID of a different data pool, specified by the parameter nodeId, in which case the function with find the IDs of data pools under that data pool.

  • getParentNodeId([string schema[, array nodeId]])

    Returns integer, the ID of the parent node

    If schema (the code of the schema) is passed, it will return the ID of the data pool above the current node that has the specified schema.

    Returns the parent of the current data pool or asset, but if nodeId is specified then it returns the parent of that data pool or asset.

  • getInheritedMetadata(string field[, integer nodeId])

    Returns whatever metadata value is currently stored for a data pool or asset (e.g. float, integer or string).

    Returns the value of a metadata field for the current node (asset or data pool).

    Because data pools are in a hierarchy, and there are assets beneath them, they inherit fields from the levels above (e.g. a room may inherit a value from a location). If the field exists and is defined on the relevant data pool or asset, that value will be returned. But if the field does not exist or is set to ”inherit“ on the relevant data pool or asset, then value is inherited from the nearest superior level that contains a value.

    This check starts from the current data pool or asset on which the Phi script is executing, but you may pass in a nodeId, such as may be obtained from the getParentNodeId(), getImmediateChildIds(), getAllChildIds(), getAllChildAssetIds() or getAllChildDataPoolIds() functions.

  • getLocationMetadata(string field[, integer nodeId])

    Returns whatever metadata value is currently stored on the location containing the current data pool or asset (e.g. float, integer or string).

    Returns the value of metadata field given by field (referred to by its code name) at the location that contains it, or that of a specific data pool or asset if the nodeId parameter is passed.

  • getMetadata((string field[, integer nodeId])

    Deprecated! See getInheritedMetadata().

  • getHistoricValue(string field, datetime timestamp[, integer nodeId])

    Returns whatever value was stored (e.g. float, integer or string).

    Looks up the value of a field at the specified timestamp.

    This checks the current asset or data pool, but you may pass in an id obtained from either the getParentNodeId(), getImmediateChildIds(), getAllChildIds(), getAllChildAssetIds() or getAllChildDataPoolIds() function to override this.

  • getMinValue(string field, datetime fromTimestamp, datetime toTimestamp[, array nodeIds])

    Returns the minimum value stored (e.g. float or integer) in the given time range.

    Returns the minimum value for the current data pool or asset, but if nodeId is specified then it returns the value from that data pool or asset.

  • getMaxValue(string field, datetime fromTimestamp, datetime toTimestamp[, array nodeIds])

    Returns the maximum value stored (e.g. float or integer) in the given time range.

    Returns the maximum value for the current data pool or asset, but if nodeId is specified then it returns the value from that data pool or asset.

  • getMetricValue(string field, datetime fromTimestamp[, integer nodeId])

    Returns whatever latest metric value was stored (e.g. float, integer or string) at the given time.

    Returns the value of the metric field whose code is given by field from the period beginning at fromTimestamp (as opposed to the end-of-period toTimestamp).

    (E.g. to get the value of a monthly metric in June, pass any timestamp during the month of June. To get the value of a daily metric on 6 June, pass any timestamp during 6 June.)

    Returns the value for the current data pool or asset, but if nodeId is specified then it returns the value from that data pool or asset.

  • getTimestamp(datetime timeStamp[, datetime timeStamp])

    Returns datetime

    Generates a timestamp as a Unixtime integer (either in seconds or milliseconds according to the portal time setting).

    Can be passed one or two parameters. If two are passed, it returns two integers in an array.