Victron VRM Portal API data integration

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

Hello Guido. My German is quite limited and rusty but I got the point.

This original post is quite old and dates from the time I did not know better and how to use Victron MQTT broker to establish a local connection rather then using VRM and be dependent on the internet connection.

Do you need to use VRM because your HA instance is not on the same network as your Victron installation? That is really the only case I can think of for using the API. If that is the case, then I’ll try to dust off my memories and help you as much as I can.

Otherwise please take a look at this post Victron/Fronius off-grid PV Energy Dashboard - MQTT and modbus integration - #32 by lsgv

Let me know.

Danke für die schnelle Antwort :smiling_face_with_three_hearts:

Ich habe die Komponenten im selben Netzwerk. Ich habe auch Werte im mqtt, siehe Screenshot.

Es ist gut erkennbar, dass die MPPT Laderegler arbeiten und im eigenen Netz ein Verbrauch ist.
Am Ende des Tages ist es aber nicht möglich, die Summer der Verbräuche zu lesen.

Ich finde nur etwas von den MPPT Ladern “/solarcharger/277/History/Daily/0/Yield” als Zusammenfassung.
Mein Ziel ist es, eine Auswertung zu bekommen, die die Tages-Ergebnisse zeigt.

Ok then, you can use MQTT. To get daily results you can do the following:

  • If you have not done it yet, create MQTT sensor in HA for whatever power flows you need, production, consumption, etc. using MQTT Sensor - Home Assistant
  • From the power (in Watt or kWatt) sensor create an energy sensor (power x time = energy) using the integration integration Integration - Riemann sum integral - Home Assistant
  • Using this sensor, create a daily Utility Meter using Utility Meter - Home Assistant
  • You can use the same energy sensor in Utility Meter to create daily, weekly, monthly etc. sensors so you can keep historical track of your production/consumption.

Let me know if this is clear or if you need any further help.

Danke für deine Mühe :grinning:

Es ist viel zu lesen.
:thinking:
Ich werde sehr bald daran arbeiten und testen, ob ich es kann. Auf dem ersten Blick, kann ich nicht sagen, ob ich weiter komme. Ich werde es dich wissen lassen.
Gruß Guido

ich habe die 3 Seiten gelesen und ich denke, ich verstehe was es für Arbeit bedeutet. Ich werde es jetzt noch nicht tun. Ein Freund hat mir mein System zusammen gestellt. Ich kann es mir nicht erlauben, da einen Fehler einzubauen. :sneezing_face:
Ich werde einfach am Monatsende, die Daten aus dem VRM Portal per Download nehmen und sie ablegen.

Es sind die Daten, die im Grunde das aussagen, was ich von der Anlage wissen will. Ich dachte, es ginge automatisch.
Ich danke für deine Zeit und Mühe.
Evtl. schaue ich in einiger Zeit noch erneut nach der Lösung… Dazu muss ich sicherer mit dem eigenen System sein.
Gruß Guido

I’m using the VRM api and works great except the grab the solar state.
“idSite”: 123184,

  "timestamp": 1683626287,

  "Device": "Solar Charger",

  "instance": 290,

  "idDataAttribute": 85,

  "description": "Charge state",

  "formatWithUnit": "%s",

  "dbusServiceType": "solarcharger",

  "dbusPath": "/State",

  "code": "ScS",

  "bitmask": 0,

  "formattedValue": "Bulk",

  "rawValue": 3,

  "dataAttributeEnumValues":

In States i get result unavailable

Did you get the text to work? Strugeling with the same.

Hello. This thread is quite old and for more than 3 years I’m now using local MQTT or modbus/TCP as implemented by Victron and detailed here
Unless you have a really compelling reason to use the API I do recommend you move to either the MQTT or modbus options.

Hello, yes I know. Old but still valueble for me.
My installation is remote, it’s on a Boat with cellular connection with a NAT ip address… I Use a RasPi that is connected to VRM. My Homeassstiant is running at home, and if I’m not mistaken the MQTT / modus/TCP will not work in my case.
But anyways. I got it to work.
Had to remove the UnitOfMesurment and change the value_template a bit…

Ok, good to know. I found the use of the API convenient in those cases but “cluncky” as best and prone to issues when Victron changed anything and the mappings didn’t work anymore.

I did use the VRM API earlier as my Victron is located in my RV.

I changed to use modbus and this HACS integration. Easy peasy to setup.
sfstar/hass-victron: Integration for Home Assistant to fetch data from the victron gx device via modbusTCP (github.com)

But llike you, my RV is om a Celuar connection so I added ZeroTier addon to Homeassistant, set up a ZeroTier network and added ZeroTier to the VenusOS as described here:
remote access to VenusOS: ZeroTier-One installation on RPi [HOW-TO] - Victron Community (victronenergy.com)
Note that this requere the use of VenusOS Large image as you have to compile ZeroTier on the device.

2 Likes