I’m not sure if this is a bug, an error in the wiki, or a simple misunderstanding on my part due to an excess of fermented grape juice. The wiki for the previousAge function states:
previousAge([device﹕attribute])
returns the number of milliseconds an attribute had the previous value
but my experience is that the number the function returns doesn’t quite match this description. Consider the following actual data from a presence sensor (for simplicity I’ve converted the results to minutes):
The age([device﹕attribute]) function correctly returns the amount of time an attribute had the current value. However, the previousAge([device﹕attribute]) function doesn’t return the amount of time an attribute had the previous value (which in my view should be 177 minutes), but rather the total amount of time since the device last began to have the previous value (177+378=555).
So in order to get the answer I’m expecting I have to write the expression as
previousAge([device : attribute]) - age([device : attribute])
That’s fine, the wiki was just misleading on this point and I’m uncertain if the function is working as intended.