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
Source: config.py:609
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: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16

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. https://www.home-assistant.io/integrations/template/#state-based-template-binary-sensors-buttons-images-numbers-selects-and-sensors

aa8756b722d86a1d92e7b5be8ccc8b882eb0dcc0

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.