V3.60 Node-RED VRM API Current Price

While trying to build a node red flow based on current price, I noticed that the published method to extract the current price using vrm-api does not work anymore. Is this ‘by design’ or a bug?
See also: Retrieve price information from VRM API in Node-Red - #3 by UpCycleElectric
Node-RED VRM API and Dynamic ESS - VictronEnergy


Requesting ‘hours now now’ does not work in v3.60
According to @dick this still works in v3.53
Retrieve price information from VRM API in Node-Red - #4 by dick
Are changes to vrm-api in 3.60 publisched somewhere?

It seems that I’ve made a mistake on that article with the screenshot, containing both start time and end time set to “now”. Fairly sure that it is better when you adjust that to have some time in between.

The release info of the vrm-api node can be found on Releases · dirkjanfaber/victron-vrm-api · GitHub.

Is there a more efficient way to get current (buy) price than pulling in multiple hours of stats data and coding a way to extract it from the object arrays?

Not yet, but we are working on adding some functionality to the API endpoints. This could be one of them.

2 Likes

What’s wrong with the period now-now?
I retrieve this info every 15 minutes and extract the prices with:
msg.payload.records.deGb[0][1]
msg.payload.records.deGs[0][1]
Works fine for me, but I probably have to set Interval to 15 minutes in June?
Does this no longer work in v3.60? What is the “proper” way of retrieving price info?

Could share the exact settings of how you do that?

[
    {
        "id": "d2d3985908d2421f",
        "type": "vrm-api",
        "z": "671e14df2ca553da",
        "vrm": "21d5d36c245c4122",
        "name": "Get DESS configuration",
        "api_type": "installations",
        "idUser": "",
        "users": "",
        "idSite": "464865",
        "installations": "stats",
        "attribute": "dynamic_ess",
        "stats_interval": "15mins",
        "show_instance": false,
        "stats_start": "0",
        "stats_end": "0",
        "use_utc": false,
        "gps_start": "",
        "gps_end": "",
        "widgets": "",
        "instance": "",
        "vrm_id": "",
        "country": "",
        "b_max": "",
        "tb_max": "",
        "fb_max": "",
        "tg_max": "",
        "fg_max": "",
        "b_cycle_cost": "",
        "buy_price_formula": "",
        "sell_price_formula": "",
        "green_mode_on": "",
        "feed_in_possible": "",
        "feed_in_control_on": "",
        "b_goal_hour": "",
        "b_goal_SOC": "",
        "store_in_global_context": false,
        "verbose": false,
        "x": 630,
        "y": 60,
        "wires": [
            [
                "505cf470300f9fbd",
                "f9bcc1283441f1ce"
            ]
        ]
    },
    {
        "id": "7e4cd656.31676",
        "type": "inject",
        "z": "671e14df2ca553da",
        "name": "Sec",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 60,
        "wires": [
            [
                "d9dc9f17.84ef68"
            ]
        ]
    },
    {
        "id": "8183d8ac.01c1e",
        "type": "rbe",
        "z": "671e14df2ca553da",
        "name": "dedup",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "septopics": true,
        "property": "payload",
        "topi": "topic",
        "x": 410,
        "y": 60,
        "wires": [
            [
                "d2d3985908d2421f"
            ]
        ]
    },
    {
        "id": "d9dc9f17.84ef68",
        "type": "function",
        "z": "671e14df2ca553da",
        "name": "Period",
        "func": "var date = new Date();\nvar min  = date.getMinutes();\nmin = min - (min % 15);\nvar hour = date.getHours();\nvar time = hour.toString().padStart(2, '0') + ':' + min.toString().padStart(2, '0');\nnode.status({fill: 'green', shape: 'dot', text: time});\nreturn { payload : time };",
        "outputs": 1,
        "timeout": "",
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 270,
        "y": 60,
        "wires": [
            [
                "8183d8ac.01c1e"
            ]
        ]
    },
    {
        "id": "505cf470300f9fbd",
        "type": "function",
        "z": "671e14df2ca553da",
        "name": "Selling price",
        "func": "var prices = msg.payload.records.deGs;\nvar price = (prices.length > 0 ? prices[0][1] : 0.0);\nvar fill = (price < 0.0 ? 'red' : 'green');\nvar shape = 'dot';\nvar text = '€' + price.toFixed(2);\nnode.status({fill, shape, text});\nmsg.payload = price;\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 130,
        "y": 200,
        "wires": [
            [
                "6ca8014dfa16a19d"
            ]
        ]
    },
    {
        "id": "f9bcc1283441f1ce",
        "type": "function",
        "z": "671e14df2ca553da",
        "name": "Buying price",
        "func": "var prices = msg.payload.records.deGb;\nvar price = (prices.length > 0 ? prices[0][1] : 0.0);\nvar fill = (price < 0.0 ? 'red' : 'green');\nvar shape = 'dot';\nvar text = '€' + price.toFixed(2);\nnode.status({fill, shape, text});\nmsg.payload = price;\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 130,
        "y": 140,
        "wires": [
            [
                "564a4ab6345ab758"
            ]
        ]
    },
    {
        "id": "564a4ab6345ab758",
        "type": "change",
        "z": "671e14df2ca553da",
        "name": "topic: buy",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "buy",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 340,
        "y": 140,
        "wires": [
            [
                "5d7f1f17f94ff588"
            ]
        ]
    },
    {
        "id": "6ca8014dfa16a19d",
        "type": "change",
        "z": "671e14df2ca553da",
        "name": "topic: sell",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "sell",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 340,
        "y": 200,
        "wires": [
            [
                "5d7f1f17f94ff588"
            ]
        ]
    },
    {
        "id": "21d5d36c245c4122",
        "type": "config-vrm-api",
        "name": "VRM"
    }
]
1 Like

Thanks @dick that is very helpful.

I imported your flow and changed the VRM API to mine (site id and token). Unfortunately still the same ‘Error fetching VRM data’ when using the ‘now’ ‘now’ setting so something did indeed change on v3.60. @dfaber

As workaround I have set the API node to use ‘now’ ‘end of day’ and due to the clean way you extracted the current prices in your flow it still seems to extract the correct, current, prices anyway as they are consistently at the front/start of the array anyway.

There was a change in victron-vrm-api v0.2.11 (commit 88d89272ae630c5b948559d10d222851cf150767) that causes the retrieval to fail when you use start=now and end=now. I’m still on version 0.2.10, so I’m not seeing it. I was not able to upgrade to the latest version 0.2.13 because there is no upgrade button. Is the version of this node tied to venusOS (I’m on v3.55)? Anyway, selecting end of day is a workaround that works for both versions.

@dfaber The commit mentioned above did not fix the original issue of retrieving one hour too much because the end times are still one second too high. When you subtract 1 second from the end value, you can also fix the regression for end=now by using 3600 instead of 0 for the value of the now selection in vrm-api.html (BTW, there are 4 options with the selected attribute).

Another thing I noticed is the use of offsets in (milli)seconds for longer periods of time in both vrm-api.html and vrm-api.js, which may cause issues during daylight savings time switches and leap years. Better use offsets measured in days or years.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.