Nodered using VRM PV forecasts

I fixed an error in the chart.
The main issue is the node, it doesn’t honour the date ranges correctly. So even though it runs from “now” it is pulling all the data for “today” so the current day’s forecast does not reduce as the day progresses and the last day is empty.
The only way around this it to not use the node and make a conventional API call sending the range required.

Ok. Many thanks for all this.
BTW. I am using the today remaining as a textfield directly from the node precisely as you suggested and that appears to work.

Hi @nickdb
Just a short follow-up if you have a sec?
For some reason yesterday the seventh day of the week always shows 0 kWh on all three systems I have installed it to so far. No big deal I guess, just a little confusing,
I have not touched anything. Are you seeing the same if I may ask?

Yes, it is a VRM’ism. The node does not seem to return data for that day when the resolution is daily. It seems to be a feature.
Only way around it is to rework the flow to use hourly stats, summing them for each day, or to dispense with the victron node and rather make a custom API call.

Edit: I checked using postman, VRM only provides 6 days of forecasts.

1 Like

I see, thanks!

If that is indeed a feature, is there in your opinion a reasonably simple way to just filter out the last day from the payload your function creates, somewhere before the chart?
That would be the object payload[6] that would need to be weeded out.

It is easy enough to just request 6 days which will avoid the empty entry.
Here is an updated function that does that.

[
    {
        "id": "0fa1146700efe238",
        "type": "function",
        "z": "9170653ac436c1aa",
        "name": "Chart PV",
        "func": "\nlet input = msg.payload.records.solar_yield_forecast;\nlet formattedArray = [];\nlet counter = 0;\n\nfor (let item of input) {\n    if (counter < 6) { \n        let date = new Date(item[0]);\n        let dayName = date.toLocaleDateString('default', { weekday: 'long' }); \n        let dayOfMonth = date.getDate(); \n\n        formattedArray.push({\n            day: `${dayName} ${dayOfMonth}`,  \n            yield: (item[1] / 1000).toFixed(1),\n            series: \"yield\"\n        });\n\n        counter++; \n    } \n}\n\nmsg.payload = formattedArray;\n\nreturn msg;\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 1000,
        "wires": [
            [
                "59b72fee48c13546",
                "5cd9f8cafabe2dde"
            ]
        ]
    }
]
1 Like

You’re a star, works great, thanks so much!

Here is also the function with 6 days formatted with date/month and with kWh as the topic so the
table is clickable with “kWh” , rather than “yield”
..if someone needs it :wink:


let input = msg.payload.records.solar_yield_forecast;
let formattedArray = [];
let counter = 0;

for (let item of input) {
    if (counter < 6) { 
        let date = new Date(item[0]);
    let dayMonth = date.getDate() + '/' + (date.getMonth() + 1);

    formattedArray.push({
        day: dayMonth,
        kWh: (item[1] / 1000).toFixed(1),
        series: "kWh"
        });

        counter++; 
    } 
}

msg.payload = formattedArray;

return msg;

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