What is wrong with this sensors template?

  - platform: template
    sensors:
      ir2mqtt_bathroom_light_power:
        friendly_name: Kopalnica Luč Poraba
        unit_of_measurement: W
        value_template: >
			{% if is_state('light.ir2mqtt_bathroom_light', 'on') %}
			   {% set brightness = states.light.ir2mqtt_bathroom_light.attributes.brightness | int  %}
			   {{ 18 * (brightness | float / 255) | round(2) }}
			{% else %}
				0
			{% endif %}

Error:

Error loading /config/configuration.yaml: while scanning for the next token
found character '\t' that cannot start any token
in "/config/sensor/energy_usage_light.yaml", line 7, column 1

There is a tab character on line 7.

You indented the line using a tab instead of spaces. I suspect it may be the first of several lines that use tabs for indenting. You’ll need to delete the tabs and replace them with spaces. You can’t use tabs to indent YAML code.

I don’t know which text editor you are using but several have a means of displaying whitespace characters such as space, tab, etc thereby making it easier to detect what is being used to create the indentation.

Thanks @123 .

That was it :slight_smile:

Suggestion based on Templating State Attribute:

Replace states.light.ir2mqtt_bathroom_light.attributes.brightness with state_attr('light.ir2mqtt_bathroom_light', 'brightness')

Thx @ardysusilo