Victron VRM Portal API data integration

Hi. Not that I know. The topics are mostly self-explanatory but it is best to navigate through them and maybe double check values with what you see on your VRM dashboard to confirm it is what you need.
The topics depend on your specific set-up but usually there is a System topic which collects most of the information you would need. MQTT Explorer has a search field on the top which you can also use.
Let me know if you make any progress.

Not longer working since 01.02 2022.
Trying different solutions, no luck.
Actual cerbo gx fw 2.8.1
MQTT Explore gets all values but hassio not getting any values :frowning:

I just upgraded directly to 2022.2.3 with no issue. Unless there is some new functionality I want to test in the new release I usually wait 1 or 2 fixes before upgrading; I’ve noticed it is more stable that way.
Back to you; are you using HA MQTT broker? Anything in the logs? Have you restarted the MQTT integration? And tried to listen to a topic directly from that integration?

If you’re still interested I’ve just posted a guide including the setup of the Energy Dashboard. You’ll find it under Victron/Fronius off-grid PV Energy Dashboard - MQTT and modbus integration

2 Likes

Sorry for the late reply. Mqtt explorer is working fine. But subscripe to listen in mosquitto gives no result. I’ve checked the mosquito conf. Still like before. I deleted all sensors but one. No change. Tried " and ’ in the sensor definition… No success.
I don’t know where to look for :roll_eyes:

As mentioned above I wrote a detailed post on this integration; Victron/Fronius off-grid PV Energy Dashboard - MQTT and modbus integration
Try to go through steps 3 to 6; on point 6 point your MQTT explorer to your Home Assistant IP to check if the connection is working.
Let me know the results.

2 Likes

@lsgv Thank you so much for your work!
I’ve been lurking like 3 years thinking: “There will soon be a Victron Integration - as popular as it is worldwide. Even more so since it is dutch and HA is strong there”.
Now I bit the bullet and finally got it to work!

I just struggle a bit with the value template to extract some information - how e.g. would I get the valueEnum Text of the charge state?

{
	"idSite": 11111,
	"timestamp": 1646491465,
	"Device": "Solar Charger",
	"instance": 288,
	"idDataAttribute": 85,
	"description": "Charge state",
	"formatWithUnit": "%s",
	"dbusServiceType": "solarcharger",
	"dbusPath": "/State",
	"code": "ScS",
	"bitmask": 0,
	"formattedValue": "Float",
	"rawValue": 5,
	"dataAttributeEnumValues": [
		{
			"nameEnum": "Off",
			"valueEnum": 0
		},
		{
			"nameEnum": "Fault",
			"valueEnum": 2
		},
		{
			"nameEnum": "Bulk",
			"valueEnum": 3
		},
		{
			"nameEnum": "Absorption",
			"valueEnum": 4
		},
		{
			"nameEnum": "Float",
			"valueEnum": 5
		},
		{
			"nameEnum": "Storage",
			"valueEnum": 6
		},
		{
			"nameEnum": "Equalize",
			"valueEnum": 7
		},
		{
			"nameEnum": "Off",
			"valueEnum": 245
		},
		{
			"nameEnum": "Equalize",
			"valueEnum": 247
		},
		{
			"nameEnum": "Ext. Control",
			"valueEnum": 252
		}
	],
	"id": 98
},

In the Victron world there are so many system configuration variants and options that I believe it would be close to impossible to create an HA integration that would satisfy everyone. It’s magic that Victron publishes so much and gives everyone access to the inner workings of their system. And we can build solid bespoke integrations using that.

In your case, I believe you are still using the REST mode, querying the cloud VRM services. I started that way too but soon found out it is suboptimal. Especially when you have all the information served on the local network both by the MQTT broker and modbus.

I recommend not getting hung up on extracting values from JSON responses as the structure of these will change over time and your carefully tuned templates will stop working. Go the MQTT or the modbus route depending on whichever you prefer or are more comfortable with. More user friendly, more robust.

A couple of posts above in this thread you’ll see a link to a more detailed guide using MQTT including the creation of power, energy, and utility counter sensors and integration with HA Energy Dashboard. Why don’t you take a look and see if that works for you, and come back with any questions you may have?

Yeah - I am sure you’re right and appreciate the recommendation to do it locally.
It’s a bit offtopic though: I use Victron stuff in my campervan. Last summer I played around with a nice Teltonika RUTX11 Router which directly does Modbus, GPS and VPN to my Home with HA. Unfortunately though it consumes about 15 Watts and during the winter months I have just enough solar for my VenusRPI :frowning:
Currently I am researching the best method to get VenusPi and RaspAP (with Adblockin, WireGuard to Home and Speedify to combine uplinks) running on one power efficient host (like a Pi4 running 3 raspberry systems as virtual machines). That would allow me a 24/7 uplink, some nice HA automations or even controlling some ESP32 for tank sensors and similar stuff.

1 Like

Hi Luis

Many thanks for your informative article on the Cerbo GX and MQTT broker. However, I already use MQTT broker in HA for Sonoff Light switches, etc, so I am not sure how to use HA with Cerbo GX in this scenario.

Can you please assist?

Many thanks in advance
Werner

Hi Werner.

After this post I kind of re-wrote it in another more complete post you can find here
Let me know if this answers your question otherwise I’ll try to help even though I’m definitely not an MQTT expert.
In the meantime, just for info, I’ve moved on from using MQTT to directly integrate Venus OS using modbusTP. There were two reasons: first, I’m also using modbus for the automation of my pool filters, SWC and sensors which do not offer MQTT so it made sense to consolidate onto one protocol rather than two. Secondly I simplify the whole setup by not having to run two MQTT brokers, one on the CCGX and another one on HA. I’m planning on following up on my post with this change but time is lacking.
Just let me know if you could sort it out.

Hi Luis

Firstly thank you for your guide. I’m completely new to all this and was able to understand for the most part.

I successfully followed your guide until step 6 and everything is working fine. I even managed to add battery soc as a sensor. But the value is not translating properly.

My question is, how do I add the data from the topics successfully so I can use it in my automations?

Also, will you add instructions for modbus integration and would this be better?

Regards

How did you get things working in the Energy dashboard when using Modbus? I have all the entities working here, but I can’t add them to the Energy dashboard due to them not having uniqueIDs.

Attached a snippet of one of my modbus configuration files. I’m using unique_id as you can see. Did you try it and if yes do you get errors?

# Power and energy flows
# COO = ConsumtionOnOutput = consommation des charges
- name: Consumption On Output
  unique_id: consumption_on_output
  state_class: measurement
  device_class: power
  scan_interval: 30
  slave: 100
  data_type: uint16
  address: 817
  unit_of_measurement: 'W'
# AIP = ActiveInPower = Puissance entrée générateur
- name: Active In Power
  unique_id: active_in_power
  state_class: measurement
  device_class: power
  scan_interval: 30
  slave: 100
  data_type: int16
  address: 823
  unit_of_measurement: 'W'

Attention, these are “power” entities, you need to transform them into “energy” entities by using the “integration” integration (yes, that can be confusing).

# Intégration des entités puissance en énergie
- platform: integration
  source: sensor.active_in_power
  method: left
  unit_prefix: k
  name: Energy from Grid

The resulting “energy” entities are what you can/need to configure into your Energy Dashboard.

Let me know if it works.

Since last core update the victron data via mqtt are not longer available.
Any Idea what has changed?

Have you looked into 2022.12: It does matter! - Home Assistant
The MQTT sensor configuration has changed. Did you catch that and changed your sensor configurations to the new standard?
As a rule, I always read the release notes in full especially the breaking changes part.

Does anybody has an example how to convert the old sensor into the new version?

That was running in the config yaml until update…

sensor:

VICTRON PV SOLAR

  • platform: mqtt
    unique_id: victron_cons_L1
    name: “victron_cons_L1”
    state_topic: ‘N/d41243b5xxxx/system/0/Ac/Consumption/L1/Power’
    unit_of_measurement: “W”
    value_template: “{{ value_json.value | float(0) | round(0) }}”

I’ve tried also this with no result

VICTRON PV SOLAR

mqtt:
sensor:

  • name: “victron_cons_L1”
    unique_id: victron_cons_L1
    state_topic: “N/d41243bxxxxx/system/0/Ac/Consumption/L1/Power”
    unit_of_measurement: “W”
    value_template: “{{ value_json.value | float(0) | round(0) }}”

To share code you need to use the preformated text using the editing sign

</>

that you find at the top of your comment text editing window. That way your exact formatting comes through and you will get better advice. This bring said, your MQTT sensor configuration should look like:

# Example configuration.yaml entry
mqtt:
  sensor:
    - state_topic: "home/bedroom/temperature"

In your case I guess this would be (note the indentations, YAML requires strict indentations to work):

mqtt:
  sensor:
    - name: “victron_cons_L1”
    - unique_id: victron_cons_L1
    - state_topic: “N/d41243bxxxxx/system/0/Ac/Consumption/L1/Power”
    - unit_of_measurement: “W”
    - value_template: “{{ value_json.value | float(0) | round(0) }}”

Give it a try and let me know if it works.

Hallo und guten Tag. Ich entschuldige mich, dass ich auf deutsch schreibe, aber da bin ich sicher, dass ich keine Fehler erkläre.

Ich habe seit 3 Wochen ein Victron System mit 1xMultiplus2, 1xCerbo GX und 2xMPPT Lader.
Ich habe es irgendwie geschafft, dass über mqtt Daten gesendet werden. Aber ich finde keine Tageswerte, wie sie im VRM gezeigt werden.
Nun habe ich gesucht und die Seite “vrm api docs.victronenergy .com/#/” gefunden.
Hier “VRM API documentation” kann ich mit der Email Adresse und dem Passwort einen Token erstellen. Egal wie ich diesen verwende, komme ich nicht weiter.
Ich wollte im nächsten Schritt hier “VRM API documentation” weiter machen.
image
Die Informationen von @lsgv Luis sind hervorragend geschrieben, aber ich habe den nächsten Schritt aus den Texten nicht erlesen können. Was kann ich tun?
Allgemein suche ich eine Möglichkeit, Tageswerte für Solarertrag und Verbrauch zu bekommen.
Danke fürs Lesen.
Guido