Config.yaml will not load after a change I made

I am trying to make a new sensor which is the sum of two other sensors.
I tried making the change using the template option in design tools and I can see that it seems to work, it calculated the correct value.
I also tried using the studio code server, frankly I am a clueless noobie

when I try to restart HA I get an error
attached is a picture of the code in config.yaml and also the error on restart

any help appreciated!!

One thing I see is you misspelled “default_config”

Also, I think you have “gridtie_totalsolar” indented too much.

thanks
fixed the misspelling on default, still wont load

I think lines 15-18 need to have 2 spaces removed from each line, they are indented too much. Im not sn expert in yaml, but I think that is not correct.

A few other things:

  1. Please don’t post images of text. Copy and paste the text and use three backticks (```) above and below if it’s YAML.
  2. Lines 13 and on should look like this:
sensor:
- platform: template
  sensors:
  ...

Naturally, don’t actually put the ellipsis. I just included that to avoid typing everything out.

  1. Technically, you should also move the lines starting from gridtie_totalsolar: back two spaces as well as Mark mentioned.
  2. Replace float with float(0)
  3. sensor.Grid_tie_input_2_1min isn’t a valid entity ID because of the capital G. Double-check what that entity actually is in your system by looking at developer tools > states.

Thanks for the help
I changed the file, hopefully like you requested.

Loads default set of integrations. Do not remove.
default_config:
# Text to speech
tts:
  - platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
ffmpeg:
- platform: template
  sensors:
      gridtie_totalsolar:
      friendly_name: "Grid Tie Solar Generation - Total"
      value_template: "{{ states('sensor.sb6_0_1sp_us_41_511_grid_power') | float(0)+ states('sensor.grid_tie_input_2_1min') | float(0)}}"
      unit_of_measurement: 'watts'

here is the new error I am getting now

Failed to restart Home Assistant

The system cannot restart because the configuration is not valid: Error loading /config/configuration.yaml: mapping values are not allowed here in “/config/configuration.yaml”, line 2, column 15

Not quite. Use this:

default_config:
# Text to speech
tts:
  - platform: google_translate
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
ffmpeg:
sensor:
  - platform: template
    sensors:
      gridtie_totalsolar:
        friendly_name: "Grid Tie Solar Generation - Total"
        value_template: "{{ states('sensor.sb6_0_1sp_us_41_511_grid_power') | float(0)+ states('sensor.grid_tie_input_2_1min') | float(0)}}"
        unit_of_measurement: 'watts'

The sensor: line that I showed in the second point in my last message is the key here.

IT WORKED
thanks very much
I have a few others to add, so I will copy exactly what you provided , cant check the math yet on the sensor til the sun shines tomorrow
thanks again

Don’t add the sensor: line again though. Just do this:

sensor:
  - platform: template
    sensors:
      gridtie_totalsolar:
        friendly_name: "Grid Tie Solar Generation - Total"
        value_template: "{{ states('sensor.sb6_0_1sp_us_41_511_grid_power') | float(0)+ states('sensor.grid_tie_input_2_1min') | float(0)}}"
        unit_of_measurement: 'watts'

      sensor_two:
        friendly_name: whatever
        ...

Also, this format is the legacy format for template sensors. It still works, but the docs encourage users to switch to the new format.

perfect, some will be subtraction, I assume just change the plus sign to a minus

@tbrennan637 The YAML mistakes you made are very common for someone who is new to YAML. YAML looks daunting, but it isn’t.

I spent €15 and 2hrs taking this online course. And it saves me a lot of mistakes and time now!

If you have already a proper understanding of JSON, you will master YAML in no time.

The course is currently on sale. I am not affiliated.

1 Like

thanks I will check it out
Im afraid I am not familiar with JSON either

If you don’t know JSON, no problem. But it stresses the fact you need to learn YAML to lower your stress levels! :joy: