Device lifecycle

Hi there
is there somewhere a detailed documentation of a device lifecycle ? which method is called when ?
to me, unless I miss something, the official Homey documentation mentions properly what happens when a device is paired (onInit, onAdded method are triggered) but I do not see what happens when a device gets unavailable for instance, what happens when the homey system resarts (e.g. when a firmware update is deployed), etc…
I read something in the SDK reference with methods like “onDiscoveryXXX” but honestly I do not understand how they work
thank you for your help