I have wrapped a rest sensor in a a template sensor because sometimes the data is not available, and rather than showing nothing, it shows the previous state, this works fine:-
I do the same for reading values from a public Air Quality service. Sometimes the service fails to respond, or some other problem occurs, so the combination of REST and Template gives me more control over the final, reported value.
Here’s what I suggest you do to avoid the problem on startup. Create a Trigger-based Template Sensor employing a State Trigger to monitor sensor.main_hdd_udma_crc_error_count_rest.
Configure the State Trigger to avoid triggering when the sensor’s value changes to unavailable or unknown. In other words, it will trigger for any state-changes except to those two.
The state of a Trigger-based Template Sensor is automatically restored on startup (so there’s no need for its template to handle this.state).
Here’s an alternative example, employing conditions to confirm the sensor’s value is not unknown or unavailable, using has_value(), and the value is a number, using is_number.