Page 1 of 1

MQTT autodiscovery

Posted: Friday 24 October 2025 17:52
by Piacco
I’m using pv2mqtt to read out my APsystems solar panels via MQTT autodiscovery. The output is shown below. I receive all values in Domoticz except for the Wh value.
I don't know why the Wh value isn’t showing up in Domoticz an how can I fix this?

Code: Select all

{
  "device": {
    "identifiers": [
      "xxxxxxxx"
    ],
    "manufacturer": "APsystems",
    "model": "DS3",
    "name": "Inverter xxxxxxxx",
    "sw_version": "V2284"
  },
  "device_class": "energy",
  "enabled_by_default": true,
  "force_update": true,
  "name": "Energy",
  "state_class": "total_increasing",
  "state_topic": "pv2mqtt/inverter/xxxxxxxx",
  "unit_of_measurement": "kWh",
  "unique_id": "pv2mqtt_xxxxxxxx_WH",
  "value_template": "{{ value_json.WH / 1000 | round(3) }}"
}
Output of the mqtt topic

Code: Select all

{"AphA": 0.17, 
"AphB": null, 
"AphC": null, 
"PhVphA": 232.0, 
"PhVphB": null, 
"PhVphC": null, 
"W": 8.0, 
"VA": 40.7, 
"VAr": 40.0, 
"WH": 470.0, 
"PF": 0.196, 
"Hz": 50.0, 
"TmpCab": 17.0, 
"TmpSnk": null, 
"TmpTrns": null, 
"TmpOt": null}

Re: MQTT autodiscovery

Posted: Friday 24 October 2025 18:05
by waltervl
Probably because there are calculations in the value template. Domoticz does not support that.

Code: Select all

"value_template": "{{ value_json.WH / 1000 | round(3) }}"
For Domoticz this probably would be enough:

Code: Select all

  "unit_of_measurement": "Wh"
"value_template": "{{ value_json.WH }}"

Re: MQTT autodiscovery

Posted: Friday 24 October 2025 18:15
by Piacco
I can't change the template, so this has to be done with node red or are there other solutions?

Re: MQTT autodiscovery

Posted: Friday 24 October 2025 19:21
by waltervl
Or ask pv2mqtt to change the config topic. Or modify the application yourself.
You can send your own modified config topic with for example MQTT explorer or mosquito_pub to test what is the correct config topic

Re: MQTT autodiscovery

Posted: Friday 24 October 2025 19:26
by waltervl
When I look in the file pv2mqtt.py the config topic is hardcoded so you can change it yourself to test.
https://github.com/MartijnVdS/pv2mqtt/b ... pv2mqtt.py

Re: MQTT autodiscovery

Posted: Friday 24 October 2025 20:37
by Piacco
Tanks, I've changed the pv2mqtt.py and rebuild the container, the value is now send to Domoticz, I've only contvert it from Wh to kWh, so this can be done with DzVents.

Re: MQTT autodiscovery

Posted: Friday 24 October 2025 20:45
by waltervl
You shouldnt. Domoticz needs Wh values, not kwh. Domoticz does the calculation to kwh for you.
So change the value template and the unit of measure as I already explained.

Re: MQTT autodiscovery

Posted: Friday 24 October 2025 21:27
by Piacco
I’ll have a closer look at it tomorrow, but this is how Domoticz is receiving the values.
These are day value's, this must be 0,474kWh 0,816kWh and 0,937kWh
Domoticz.JPG
Domoticz.JPG (19.7 KiB) Viewed 234 times

Re: MQTT autodiscovery

Posted: Friday 24 October 2025 21:30
by waltervl
You because you did not do what I advised......
Change into the pv2mqtt.py config topic

Code: Select all

"unit_of_measurement": "Wh"
"value_template": "{{ value_json.WH }}"

Re: MQTT autodiscovery

Posted: Friday 24 October 2025 21:47
by Piacco
Oops, my reading skills are not the best! You were right—I've switched it to 'Wh' and voilà, the values are finally behaving. Thanks again!" 😄

Re: MQTT autodiscovery

Posted: Sunday 26 October 2025 9:49
by Piacco
The device is showing up as General kWh, Electricity (instant and counter), these device needs two value's instant and counter, how do i get the instant value into the device? The value instant W is available.

Code: Select all

{
  "device": {
    "identifiers": [
      "xxxxxxx"
    ],
    "manufacturer": "APsystems",
    "model": "DS3",
    "name": "Inverter xxxxxxx",
    "sw_version": "V2284"
  },
  "device_class": "power",
  "enabled_by_default": true,
  "force_update": true,
  "name": "Power",
  "state_class": "measurement",
  "state_topic": "pv2mqtt/inverter/xxxxxxx",
  "unit_of_measurement": "W",
  "unique_id": "pv2mqtt_xxxxxxx_W",
  "value_template": "{{ value_json.W }}"
}

Re: MQTT autodiscovery

Posted: Sunday 26 October 2025 23:57
by waltervl
I have no Idea how the counter value should be added with MQTT autodiscover.

Re: MQTT autodiscovery

Posted: Wednesday 29 October 2025 11:15
by FlyingDomotic
Neither me... but if you can't find a way with MQTT Autodiscovery, yo may have a look at https://github.com/FlyingDomotic/domoti ... per-plugin.
An example of MqttMapper configuration file could be:

Code: Select all

"My KWh counter" : {
		"topic": "pv2mqtt/inverter/xxxxxxxx",
		"type": "248", "subtype": "1", "switchtype": "0",
		"mapping": {"item": "W;WH"}
}