Trying to create JSON structure for MQTT

Format your code correctly. Then you’re likely to get people helping you because they can copy and paste it.

Edit: that’s better :slightly_smiling_face:

Note that pv and L1 should be dictionaries but you are creating them as lists.

Just do it directly:

{% set output = {
  "pv": {
    "power": states('sensor.growatt_grid_active_power'),
    "voltage": states('sensor.growatt_output_voltage'),
    "L1": {
    }
  }|tojson
%}

… with the other values filled in appropriately.

1 Like