Template with subtractions

Good day everyone… I’m try to do a template that measure the charge of a battery measuring the difference betwin the KWH ingoing and the kwh outgoing, but i have always error report from HA (states.sensor.energy_meter_1_energia - states.sensor.inv_gar_out_energia) = Battery_Garage_KWH
Can you please check this code for me? Or translate in new standards?

# Calculated Value Sensor : Battery_Garage_KWH
  - platform: template
    sensors:
      Battery_Garage_KWH2:
        entity_id:
        - sensor.energy_meter_1_energia 
        - sensor.inv_gar_out_energia
        value_template: =
          {set BatGarIn2 = states.sensor.energy_meter_1_energia.state| float }
          {set BatGarOut2 = states.sensor.inv_gar_out_energia.state| float }
          {{ (BatGarIn2 - BatGarOut2)|round(1) }}

Tnx

Best regards.

Critical Issues that need to be addressed:

  • Rule #1 of Templates: All templates must be surrounded by quotation marks or preceded by a block scalar indicator. The = symbol you have used after value_template is not a valid block scalar indicator, change it to >.
  • The top line needs to be deleted or commented out since it is not valid YAML.
  • entity_id is not a valid configuration variable for template sensors.

Non-Critical Issues: