Posted On: Aug 11, 2021
AWS IoT SiteWise now supports three new enhancements to AWS IoT SiteWise formula expressions to allow users greater flexibility in monitoring their IoT assets in near real-time.
AWS IoT SiteWise transforms now supports passing a variable to the timestamp function as an argument in addition to the already existing timestamp functionality which takes in no arguments and returns the current timestamp value. The timestamp(variable-name) function returns the timestamp for the specified variable.
AWS IoT SiteWise transforms now also supports a new temporal function called pretrigger(). The preTrigger(variable-name) function returns a variable value prior to the update that triggered the calculation. Customers can identify durations of states and state transitions by using the pretrigger function. Consider an example where a manufacturer uses AWS IoT SiteWise to monitor the status of a machine. The manufacturer tracks a measurement current_state that represents the manufacturing process, where 0 indicates that the machine is in the cleaning state and 1 indicates that the machine is in the manufacturing state. If the machine stays in the cleaning state longer than expected, the manufacturer might want to investigate the machine. A transform like cleaning_state_duration with a conditional logic expression of if(pretrigger(current_state) == 1, timestamp(current_state) - timestamp(pretrigger(current_state)), none) can help determine how long the machine has been in the cleaning state.
Additionally, AWS IoT SiteWise now also supports nested expressions within aggregation functions. Prior to this feature, customers had to make modifications to variables by writing additional transforms before they could use these variables within aggregation functions. With the support for nested expressions within aggregation functions, they will be able to write a multi-level nested expression within the aggregation function itself. For example, formula expressions like avg(x*(x-1)), sum(x/2 )/avg(y^2 ), sum(avg(x^2 )/2) , sum(x/2, y*2) will now be supported within aggregation functions.