Lots off errors by templatesensor

Thanks for insisting on those, it also annoyed me a lot and had to redo all my templates in a very similar method than @fanaticDavid mentioned, I got rid of most errors by changing every template sensor like this:
......value_template: >- ........{%- if states("sensor.sensor_name") != "unknown" -%} ........{%- else -%} ........{%- endif %}

I was still getting a few because I missed your point exactly, so thank you!!

NB: I used multiline strip as the results looks much nicer in the templater, the template works if the last part of the endif doesn’t have a “-”.

I’ve also started to read about tags (forcing the value type with !!int or !!str) and think I’ll could now do a lot more simplification if I can find a way to re-use blocks like mentioned on wikipedia but better explained with an example here http://stackoverflow.com/a/9197237/6305035

CORRECTION: Wemo Binary Sensors seems to be a different story as they get initialized later on, still trying to find a way to manage the startup errors.