WHEN

Parameters

OrderNameTypeDesc
1pointspoint listThe point(s) containing the history to search through
1comparisonFunctionThe comparison function

Returns

Places an time list on the stack.

Description

This function returns a list of times - based on the history of the points - where the condition is true.

You can use this function to ask questions such as 'When was the door open?' or 'When was the machine consuming more than 2.5A?'

Example

Let's assume you have a power meter on your refrigerator, and you'd like to know exactly when in the day you were consuming more than 2.5A of power.

We can do that with the following query…

'Fridge' ASSET 'Current' PROPERTY VALUES { “range”: “24 hours”, “method”: “raw” } GETHISTORY [ 2.5 GREATER ] WHEN

This function will return a time list, such as the one below…

[ { “from”: “2021-02-02 10:00:02”, “to”: “2021-02-02 10:31:03” }, { “from”: “2021-02-02 14:11:22”, “to”: “2021-02-02 15:05:30” } ]

…which indicates that the fridge was running between 10:00 and 10:30, and again from 14:11 to 15:05.

See Also