Help with JSON Code to Capture Solar Data

My new GoodWe inverter unfortunately will not enable direct connection from HA, so I have to capture the data via the GoodWe SEMS portal API.

There’s no SEMS integration in HA, so I’ve configured Domoticz with the SEMS API plugin and output the data on MQTT as a client to my Mosquito server, and here’s what comes out.

Here’s the MQTT topic:-
domoticz/out/GoodWe Inverter - Inverter output power (SN: 55000DSF229W0310)

and the output below…

{
	"Battery" : 255,
	"LastUpdate" : "2022-12-20 10:44:01",
	"RSSI" : 12,
	"description" : "",
	"dtype" : "General",
	"hwid" : "2",
	"id" : "00020004",
	"idx" : 4,
	"name" : "GoodWe Inverter - Inverter output power (SN: 55000DSF229W0310)",
	"nvalue" : 0,
	"stype" : "kWh",
	**"svalue1" : "1780W",**
	"svalue2" : "181400.0",
	"unit" : 4
}

To my surprise the SEMS API offers the “svalue1” which is outputting in Watts, and not kWh as per the screen from Domoticz. So this is not a bad thing, as my previous inverter provided watts.

Only issue, I am not that great with unravelling json to feed it into Home Assistant, so I may need someone way smarter than me to help decipher the MQTT data and feed it into the Energy Dashboard. And I figure I need to somehow remove the W on the end of the watts data?

I obtained the data from my old inverter and interfaced it into via MQTT, and it worked well. Here’s the Configuration.yaml entries from my old inverter setup…

# kWh Solar from Domoticz

 - platform: mqtt
   name: "Solar Inverter"
   state_topic: "domoticz/out/8"
   device_class: power
   unit_of_measurement: 'W'
   value_template: "{{ value_json.svalue1 | int }}"

 - platform: integration
   source: "sensor.solar_inverter"
   name: "Solar Inverter KWh"
   unit_prefix: "k"
   round: "2"

So all I really need is some help to modify the value_template line to interpret the MQTT feed from Domoticz so HA can understand the data. Or am I missing something?

Any advice appreciated.

adding (0) to give a default 0 …else when nothing comes it produces an error

{{ value_json.svalue1[:-1] | int(0) }}

Hi There @vingerha thank you so much for the help. I’ve implemented the json and restarted my HA, so lets see what happens. Again, thank you for the guidance… I am really bad at json :crazy_face:

Update: Appears to all be working, thanks again.

In this case it is not json but jinja but do not be fooled… I am not by far the expert as others are…just learning by doing.
On the sensor, via development tools states, you can select yours and update state and (!) attibrutes with a value, then you can see if it works…it will overwrite when new data flows in (or when you set it back)