Detect when an object has stopped

An object is falling and if it collides with a plane, as it is a sphere it can rotate, I need to call a function when this object is 100% still, how can I do that? thanks

if(this.entity.rigidbody.linearVelocity.length() === 0) {
 //stop moving
if(this.entity.rigidbody.angularVelocity.length() === 0) {
 //stop rotating

wow thanks