How can we get the history of past events from a motion device?

I"m not really sure what a lambda function is, but I discovered this the other day that might help get you on a path to what you’re after?