Bad indentation of a mapping entry (line: 14 column: 32)

Hi

I have a Go-e charger that Im trying to feed with solar PV surplus data. I use the Go-e charger MQTT integration from HACS. On the Github there is this example that I’m trying to use, but I get an error I can’t figure out. The error is "Bad indentation of a mapping entry (line 14 column:32). Line14 is the line beginning with payload: and column32 is according to vsCode in th middle of }}{{ before states. Hope that makes sense :slight_smile: Maybe someone can help me out with this.

alias: go-e Surplus Charging
description: "Simple automation to update values needed for using solar surplus with go-e Chargers"
trigger:
  - platform: time_pattern
    seconds: /5
condition: []
action:
  - service: mqtt.publish
    data:
      qos: "0"
      # Change to your charger ID here
      topic: go-eCharger/000000/ids/set
      # Please provide your own entities here, as described above
      payload: {{'{"pGrid": '}}{{states('sensor.grid_import_export_state')}}{{', "pPv":0'}}{{', "pAkku":0}'}}
      retain: false

Your payload template must be enclosed in quotes if it’s a single line as shown. As you have a mixture of single and double quotes in it already, probably easier to write like this:

      payload: >
        {{'{"pGrid": '}}{{states('sensor.grid_import_export_state')}}{{', "pPv":0'}}{{', "pAkku":0}'}}

Thanks a lot. That did the trick. Probably has changed after the Github automation example was written.

The example (and entire repository) was created roughly a year after that “important rule” was added to the documentation. AFAIK, it was also an unwritten important rule before that.

You might want to raise an issue on the integration’s repository.

1 Like