Creating template

Your problem is not in the template itself. It looks to me like you’ve pasted it in the wrong place, but it’s hard to tell from the information you’ve supplied.

Paste in your sensor configuration from configuration.yaml including surrounding sections (particularly the bit before containing module-url), and format it properly please. Read this before responding:

Also, you’re using the legacy template sensor configuration. Consider using modern configuration instead, under the template: heading. See here: