question

graham-willsher avatar image
graham-willsher asked

Node Red VRM API to get installation data from Victron

Hi,

Please excuse the simple question.

I am trying to get installation data via the VRMAPI via node red.

I am just looking for a bit of guidance as to how to code the node red to make the necessary PUT's/GET's to get the information.

I have tried HTTP request in node red putting in my usename and password (which I have tested to see that it works within the VRM API documentation site), but within node red I just get 'invalid credentials'.

I have done this by setting the msg.data value to be my username and password, msg.url to be the 'https://vrmapi....' url, and the method to be POST, then injecting this into a http request.

If anyone could point my in the right direction to get this to work it would be appreciated.

The reason for me trying to get the installation data is so that I can use the past usage data along with the forecast data available to better utilise my batteries and to be able to programmatically control how much energy I pull from the grid in the Octopus cheap electricity window on a daily basis.

Thanks for any help,

Graham.




VRMNode-REDapi
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

4 Answers
fish avatar image
fish answered ·
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

Dirk-Jan Faber (Victron Energy) avatar image
Dirk-Jan Faber (Victron Energy) answered ·

Have you read https://vrm-api-docs.victronenergy.com/#/ ?

Basically you just need an access token. Go to the access token part of VRM and add a new token. Name the new token Node-RED or something that your mind will link to Node-RED. Once generated, store the access token in your password vault as you won't be able to retrieve it again.

The https://flows.nodered.org/node/victron-vrm-api also uses this method.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

graham-willsher avatar image
graham-willsher answered ·

Hi Fish/ Dirk-Jan Faber,

Thank youo for your replies, they have helped guide me in the correct direction to get this working. The main issue was that I had a payload being injected to my HTTP request when GETting data. Once I had worked that out I got the replies that I was expecting.

I now need to tidy things up and use the permanent access token as recommended by Dirk-Jan and then manipulate the received data.

Fish, thanks for your link to the SOC flow. I will be lloking at that in more detail in due course. I am trying to get historical data usage from my site, so that I can (very roughly) calculate the amount of electricity that I use each day on an hourly basis and along with your solar forecasting work out the smallest SOC that I need to set daily when charging my batteries from the Grid in the Octopus cheap window (02:00-05:00). I know that it won't be the most accurate, as we can never be exactly sure what today's usage is going to be based on historical usage, but it will give me a start.

This will hopefully lead me to be able to utilitise my bateries better and reduce the amount of electricity that I pull from the grid in the cheap window, which in turn will enable me to capitalise on my invesment. (charge my batteries using free solar, then discharge this free electricity in the Octopus premium export window (16:00-19:00).

Once again thanks,

Graham.

4 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

graham-willsher avatar image graham-willsher commented ·

Hi Fish/Dirk-Jan Faber,

Further to my above post I have now managed to get my Node Red flow working as I was aiming for.

That being, getting historical usage data for the last 31 days, to give me an average daily usage, then combine that with the solar forecast for the following day. I can then calculate the SOC that I need to set for the following day to ensure that I don't discharge my batteries below a minimum amount. e.g. Try not to use grid electricity during the daytime.

It is early days yet, but the SOC figures that I have at the moment seem to be right.

In theory the predicted SOC should be more in the winter months and lessen as we approach Summer, due to more solar production.

This hopefully will allow me to make far better use of the solar production and battery storage in the Summer, and be able to get a better financial return.

Graham.

3 Likes 3 ·
angeletor avatar image angeletor graham-willsher commented ·
Hi Graham,


It's amazing to read what you have achieved. Would you mind sharing the schemes??? I'm still pretty noob with node-RED programming (old time C/BASIC/Asembler programmer here) and having a working schema helps me a lot to modify it to suit my needs...

Thank you!!!

Angel

0 Likes 0 ·
graham-willsher avatar image graham-willsher angeletor commented ·

Hi Angel,

Sorry for the delay in replying, for some reason I can't get my messages from the forum sorted (I either get too many or none at all).

Please find attached the node red that I currently use. You will need to add in your site number and your token to access the Victron API. It might not be the best bit of coding, but it works for me :)

I have changed things slightly since the previous post, as I now have more batteries and have moved to an EV tariff that charges me just 0.075 GBP/kWh from 23:30 - 05:30 daily.

I now charge the batteries more fully to make use of the cheap rate. In the Summer months the logic should then allow me to do most of the battery charging from my PV's, as per my original thoughts.

If anything needs any further explaination just let me know.

flows (2).txt

Screenshot 2024-01-12 150938.png

Thanks,

Graham.

0 Likes 0 ·
Philip avatar image Philip graham-willsher commented ·

Hi,

Yout flow is great, but you might be interested in this: https://gbboptimizer.gbbsoft.pl
This the same what You made but way more complex.


0 Likes 0 ·
lucas-rodas avatar image
lucas-rodas answered ·

hi Graham, Can you send me your Instagram and help me with some problems I have with the victron energy node that is implemented in node red? I have several problems and I am new to this

1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

graham-willsher avatar image graham-willsher commented ·
Hi @Lucas Rodas,


What issues are you having?

I am no expert, but am happy to try and help. If you post what you are trying to achieve and what you have tried and what appears not to be working. Then I can have a look.

Thanks,

Graham.

0 Likes 0 ·