{% endif %} - can not read a block mapping entry......in the configuraton.yaml

Hello,

I have the next problem and I wish that someone helps me!
Warrnig_ I’m a noob

I have the motor which is connected to a socket (tasmota,mqtt) and I want to monitor 2 things.
The first one is to measure when the motor is operating or standing still and the second is that I want to create a sensor that will measure how much time passed when the motor is moving and when the motor is standing. When the motor is operating its power is > 2.5. When the motor is stoped then power is less than 2.5

  - platform: template
    sensors:
      motor_moving_resting:
        friendly_name: "MotorMan"
        unit_of_measurement: "Watts"
        value_template: "{{ states("sensor.uticnica_12_12_energy_power") | float}}
        {% if states('sensor.uticnica_12_12_energy_power') | float > 2.5 %}Operating
        {% else %}Standstill
        {% endif %}

When I test this code in Developer tools - Templates, I can see it’s working ok.

When i paste this code into conf.yaml I get next error:

Can anyone help me how to solve this error:

can not read a block mapping entry; a multiline key may not be an implicit key at line …:
{% endif %}
^
Thx

1 Like
  - platform: template
    sensors:
      motor_moving_resting:
        friendly_name: "MotorMan"
        unit_of_measurement: "Watts"
        value_template: >
          {{ states('sensor.uticnica_12_12_energy_power') | float(0) }}
          {% if states('sensor.uticnica_12_12_energy_power') | float(0) > 2.5 %}Operating
          {% else %}Standstill
          {% endif %}

The Template Editor doesn’t check for valid YAML syntax, it only evaluates Jinja2 templates. Your example contained a YAML syntax error so that’s why it failed when you used it in configuration.yaml.

LoL

I’m trying since the last night to figure out what is a problem and you solve it in a second!

respect Taras and thank you very much!

1 Like