Victron VRM Portal API data integration

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

This topic was opened 5 years ago and except in very particular circumstances is not useful anymore so I wanted to close it but can’t find a way to do that on the forum.
On the subject of integrating Victron equipment with HA here is a short summary for those ending up here:

  1. Use the VRM API as explained in this thread
    When? If your Victron installation is remote and it’s only connection to the “world” is via VRM
  2. Use MQTT as explained in many threads and specifically here
    When? If you’re familiar with MQTT and envision the use of, for instance, Red-Node, for logic programming and automations
  3. Use modbusTCP either using DYI config or using the excellent HACS integration from @sfstar you can find here
    When? If you’re familiar with modbus and like to keep it simple

After having used all 3 methods I am now and for the foreseeable future using modbus because I have other modbus integrations in my HA such as for instance swimming pool filters/clorinator, Fronius inverter, etc. which reduces the number of integration and keeps it simple. But this is a purely personal choice, feel free to test and try and break and share your experiences.

If you want Victron’s opinion please read this post by Matthys Vader on the subject. you can find the complete thread here

3 Likes

Hello, please help??
I somehow tried everything, but:
HOW SHOULD I ADD THOSE SENSORS TO LOVELACE !!
I DON’T SEE ANY ICON ON MY VIEW.
Thank you.

Do you really need to use the VRM API or can you not use MQTT or modbusTCP?

I am using Modbus TCP and it works great. It’s just matter of downloading the Modbus TCP register list from Victron technical info, and then write sensor definitions for selected parameters, for example

  - name: "ESS battery SoC"
    unique_id: "PAkBZRSAZWIeJkdNQ2JwAKFTVsmtzrsd"
    unit_of_measurement: "%"
    scan_interval: 20
    slave: 100
    address: 843
    data_type: uint16
    device_class: battery
1 Like

Please do not close this topic!

If you can use modbus or MQTT this is of course a much better way, but if you use globalLink the VRM api is the only way to integrate.

I have a cabin with solar power only, and being in Norway and in a northfacing slope i have zero sun from Nov - Mar so having anything other than a globallink to watch my system is impossible without draining the batteries.

The globallink use 4g LTE-M to send data each 15 mins directly to the VRM. It use very little energy, but cannot be remotely accessed any other way than by the VRM api.

The globalLlink have a relay so i can turn on my 4g wifi-modem and webcams etc to make quick checkouts and then turn off everything except the globallink again.

BTW the api have a full web interface for testing out all the calls from a browser at

https://vrm-api-docs.victronenergy.com/#/

I didn’t see this in the thread. If its there i apologize.

Very easy to test out all calls, just remember that the tokens should be written without the surrounding “<>” signs (Took me a while to figure that one out…)

-Goffen

1 Like
Bearer <eyJ0e....>  = "success": false

Bearer eyJ0e....      = "success": TRUE!!

-Goffen

Hello, I have a problem and hope someone can help:
I connected via VRM API.
vrm is connected.
However, I don’t get any battery data.
I have the data set from here:

  • platform: template
    sensors:
    vrm_temp:
    friendly_name: ‘VRM Battery temperature’
    value_template: ‘{% for item in states.sensor.vrm_data.attributes.records if item[“code”] == “CT” and item[“instance”] == 521 %}{{ item[“formattedValue”][ :-2] | float() | round(1) }}{% endfor %}’
    unit_of_measurement: ‘°C’

    battery:
    friendly_name: ‘VRM Battery’
    value_template: ‘{% for item in states.sensor.vrm_data.attributes.records if item[“code”] == “SOC” and item[“instance”] == 288 %}{{ item[“formattedValue”][ :-2] | float() | round(1) }}{% endfor %}’
    unit_of_measurement: ‘%’

Data from VRM:
sensor.vrm_data

success: true
records:

  • idSite: *******
    accessLevel: 1
    owner: true
    is_admin: true
    name: Electrics
    identifier: *********
    idUser: *******
    pvMax: 0
    time zone: Europe/Berlin
    phonenumber: zero
    notes: zero
    geofence: zero
    geofenceEnabled: false
    realtimeUpdates: true
    hasMains: 0
    hasGenerator: 0
    noDataAlarmTimeout: null
    alarm monitoring: 1
    invalidVRMAuthTokenUsedInLogRequest: 0
    syscreated: 170*****
    isPaygo: 0
    paygoCurrency: null
    paygoTotalAmount: zero
    idCurrency: 1
    currencyCode: EUR
    currencySign: €
    currencyName: Euro
    inverterChargerControl: 0
    shared: false
    device_icon: battery
    friendly_name: vrm data

Hi. Difficult to say with the data you provide. Have you checked the vrm_data output for the instance carrying the SOC?
But before that, are you using the API because your HA instance is not on the same network/site as the Victron installation, or for another reason? Could you use MQTT or modbus?

I suspect that I inserted incorrect data by copying it. Do I get the sensor data via Postmann or are they standard values?
Yes, I’m not on the same network, otherwise it would be easier.

Hi, my configurations stopped working. I’m running 2024.4.0
No changes have been done to the configuration. Any

I have tested with postman and Token works.
Also tested in Template Editor and i get a ‘value_json’ is undefined


Any idea what could be the problem?

Have you looked into the logs?

Yes, but overlooked the fact that you can’t have more than one "sensor: " in configuration.yaml.
Had to comment out the Nordpool one, now I have to figure out how to use both Nordpool and VRM sensor configured.

sensor: !include sensor.yaml
sensor nordpool:

  • platform: nordpool
    VAT: True

You can have as many sensors as you want, just declare them on separate lines. Or better, if they’re based on templates, put them in a separate template.yml file and include the file. Anyway, glad you found out what the issue was.

Thanks, that’s what I ended up doing.


All good now.

Hi,

I added this to my config and see both Victron and HomeAsstant in the MQTT explorer (and my Javascript WebSocket APP)

mqtt_statestream:
  base_topic: homeassistant
  publish_attributes: false
  publish_timestamps: false