There are tons of forum posts of people who also face this problem but it seems there is no nice solution to this: In my case, the entities of my PV inverter become unavailable once the device shuts down over night. The entities have a red exclamation mark next to them and all template sensors that use them (e.g. to calculate the daily yield of different systems) also show “unavailable”.
However, if I click on a respective entity I can see the last value and all previous values of the entity in its history.
It would be nice if one could use a filter or if there was a default attribute “last_value” populated for each sensor that could be used to avoid the above issues, i.e. to ensure that all other entities using this value still work.