How To Get Template Entity Values To Persist Through Restart

There’s the important clue. Your pyscript is setting the attributes of cover.curtains_side.

In other words, your pyscript is setting values that only exist in Home Assistant’s state machine and disappear after a restart. It’s no different than using the popular set_state.py python_script (developed by rodpayne).

The technique you’re using will never produce values that survive a restart. Upon startup, the template Cover will always initialize itself to whatever it finds in position_template which, according to your example, will be 100.