Problem creating template

Hi all,

I’m quite new to this. Followed some youtube instruction while trying to create a template.
Please find the error I’m getting:
Logger: homeassistant.config
First occurred: 1:37:38 AM (2 occurrences)
Last logged: 1:37:42 AM

Invalid config for ‘template’ at template.yaml, line 2: required key ‘state’ not provided Invalid config for ‘template’ at template.yaml, line 4: ‘state’ is an invalid option for ‘template’, check: state
Screenshot 2024-03-26 at 8.16.48

Hello and welcome.

Please don’t post images of text. Post the text correctly formatted for the forum as per point 11 here:

This allows us to easily edit your config to help you.

In answer to your question, your indentation is way off. Indentation is very important in YAML. Compare your sensor to the example shown in the documentation.


seems like you might be new to yaml… you might consider using the UI to help you… You can create most of this sensor by going to settings- automation &scenes - helpers - create helper

Then choose template. Then template a sensor.

Now you only need to write the template part

Thank you guys. It is now solved.