Template Sensor driving me nuts... help please

Hello

I’m trying to create a very simple template sensor, to show how much in £ running an electrical device costs. If I put into the Dev tools, template, it works perfectly… but i get this error when restarting HA. Anyone point me in the right direction please?

2019-11-23 10:31:35 ERROR (SyncWorker_0) [homeassistant.util.yaml.loader] while parsing a block mapping
  in "/config/sensor.yaml", line 779, column 9
expected <block end>, but found '<scalar>'
  in "/config/sensor.yaml", line 781, column 38
2019-11-23 10:31:35 ERROR (MainThread) [homeassistant.bootstrap] Error loading /config/configuration.yaml: while parsing a block mapping
  in "/config/sensor.yaml", line 779, column 9
expected <block end>, but found '<scalar>'
  in "/config/sensor.yaml", line 781, column 38
  - platform: template
    sensors:
      heater1234_cost:
779        friendly_name: Heater Cost
        unit_of_measurement: '£'
781       value_template: '{{ (states('sensor.heater_energy_today') | float * 0.16653) | round(4) }}'

Look where the first single quote in the template pairs with the next:

value_template: '{{ (states('

To prevent this use double quotes outside the template:

 - platform: template
    sensors:
      heater1234_cost:
        friendly_name: Heater Cost
        unit_of_measurement: '£'
        value_template: "{{ (states('sensor.heater_energy_today') | float * 0.16653) | round(4) }}"
2 Likes

Oh god I thought I had already tried that!! thank you do much. 3 hours I wasted on this! :smiley: