Downtime sensor

Hi

I am wondering whether there is an integration which would give me a sensor (or some other means) of fiduring out how long HASS was down when it starts – it doesn’t need to be super accurate, so even some sort of counter from the last log entry before restart would be great.

I’d like to do some things on HASS startup but only if something went wrong and it was down for a long time, rather than at every reboot.

Thanks!