Retain last state change data of a sensor after reboot

This is a frequently discussed topic on the forum:

A cursory look at the codebase indicates that the last_updated and last_changed variables are defined whenever the class is instantiated ie. on a restart?