Entity has non-numeric state since 2024.8

I had my tariff set with template sensor (in templates.yaml) like this for 2 years

    - sensor:
        - name: "Мосэнергосбыт"
          unique_id: 220_price
          unit_of_measurement: "RUB"
          state: "
            {% set time = now().hour * 60 + now().minute %}
            {% set startTime = 23 * 60 + 0 %}
            {% set endTime = 7 * 60 + 0 %}
            {% if time >= startTime or time <= endTime %}
            {{'2.09'}}
            {% else %}
            {{'5.5'}}
            {% endif %}
            "

Energy settings used this sensor as current price for electricity.

Since 2024.8 i got error saying

Entity has non-numeric state
The following entities have a state that cannot be parsed as a number:
sensor.mosenergosbyt (unavailable)

And sensor is unavailable.
However when checking template in devtools i get correct numeric state

What am i missing since 2024.8 ?
Did some includes or templating changed ?

Change it to this (multiline template).

    - sensor:
        - name: "Мосэнергосбыт"
          unique_id: 220_price
          unit_of_measurement: "RUB"
          state: >
            {% set time = now().hour * 60 + now().minute %}
            {% set startTime = 23 * 60 + 0 %}
            {% set endTime = 7 * 60 + 0 %}
            {% if time >= startTime or time <= endTime %}
            {{'2.09'}}
            {% else %}
            {{'5.5'}}
            {% endif %}

If you’re interested, you can reduce the template to this:

    - sensor:
        - name: "Мосэнергосбыт"
          unique_id: 220_price
          unit_of_measurement: "RUB"
          state: >
            {% set t = (now().hour, now().minute) %}
            {{ iif(t >= (23,0) or t <= (7,0), 2.09, 5.5) }}

Thanks for reduced template!
But i still get this sensor as unavailable - i checked all indents and structure - found that i had some template in configuration.yaml and some in templates.yaml.
Now i can’t combine correctly both of them in templates.yaml.

- sensor:
    - name: "Мосэнергосбыт"
      unique_id: 220_price
      unit_of_measurement: "RUB"
      state: >
        {% set t = (now().hour, now().minute) %}
        {{ iif(t >= (23,0) or t <= (7,0), 2.09, 5.5) }}

- trigger:
      - platform: state
        entity_id: binary_sensor.nasos
        to: 'on'
      - platform: time_pattern
        hours: '/1'
    sensor:
      - name: Water Pump Hourly Counter
        unique_id: 6759e0f7-e104-4690-a700-3fce4d92bddc
        state_class: total_increasing
        state: "{{ 0 if trigger.platform == 'time_pattern' else this.state | int(0) + 1 }}"

This gives me error “Error loading /config/configuration.yaml: while parsing a block mapping in “/config/templates.yaml”, line 9, column 3 expected , but found ‘’ in “/config/templates.yaml”, line 15, column 5”.

How it can be fixed ?

Upd. Moved price template from yaml to GUI, and trigger template back to configuration.yaml.