Node Red Nordpool API, need help filtering the message

Hey.
I'm using a flow copied from here: https://discourse.nodered.org/t/extract-value-from-array-based-on-timestamp/56954

It's workin ok, but the problem is that the price changes at the wrong time :

Price change at xx:30, and the price is wrong.

I know the issue is on this function node, its is rounding to nearest hour, as it is saying.

const data = msg.payload;
const now = new Date();
const nearestHour = roundDate(now);
const findTimestamp = nearestHour.valueOf();

msg.payload = data.find(e => {
    return (new Date(e.Timestamp)).valueOf() == findTimestamp;
});

return msg;

function roundDate(date) {
    date.setHours(date.getHours() -1 + Math.round(date.getMinutes() /60));
    date.setMinutes(0, 0, 0);
    return date;
}

But I dont have any idea how to fix it, I'm a total noob with javascript.
Price should change at xx:00:00 and hold the price to xx:59:59

Any help with function node is highly appriciated :slight_smile:

This kind of data is meaningful to present with bar chart. Bar per hour. Elegant and easy to read.

Great. I'll keep that in mind.

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