That' correct.
And if you query it now (prices not yet available) you'll get this situation:
And this code goes into a function node running every hour (separate flow) or is this also just triggered once a day?
I can defenitly see the benefits of having a wider range of prices, including history, but I'm not sure this will solve the problem that I'm having, to fetch the "next hours price" each hour. from the array.
That's the function after the nordpool-api node. I make day-ahead query once a day at 15:00 (local time).
In case that query had failed, I have check for data existence and then i do that query periodically until there is data.
To get price for next hour it is just a date manipulation. You can of course use one of many tools for date manipulation but it is simple enough with plain JavaScript
let prices = global.get('nordpool') || []
if (prices.length== 0) {
return
}
let d = new Date()
d.setMinutes(0);
d.setSeconds(0);
d.setMilliseconds(0);
d.setHours(d.getHours() + 1)
let price = prices.find(el => el.x == d.getTime())
node.warn(price)
msg.payload = price
return msg;
I still just get an array[24] of todays prices running this.
I have the flow like this:
Timestamp -> (Code from post 19) -> Nordpool API -> (Code from post 17) -> Debug
Is that wrong?
This is what nordpool-api node's help says
As I'm using old version, who can tell why and how it behaves so don't rely on my experiences.
But no worries, after day-ahead prices published, I'm sure you'll get those too.
Everything seems to be working ok, except I suddently got an error "TypeError: nordpool.find is not a function" in the debug.
I get the array in msg. payload with 48 objects.
I have copy/pasted your code, but it gives this error.
Any idea what it can be because of?
Can't tell based on that less of info.
Known that copy-paste is dangerous way of programming but the error indicates that the nordpool is not an array. So debug it to be sure.
Does the above code compare the "generated date+time (+1h)" and the "date+time" in the nordpool-array independant of format?
Format is expected to be as that big function stores it.
x is timestamp
y is price
That code is searching in array for element with matching timestamp
Hi, I'm really struggling with the global variable "nordpool", as it seems to not be saved globally.
I'm wondering if I'm missing out on anything in the flow itself?
Unfortunately I'm running the Node REd on my Raspberry pi, so I'm having trouble to take a screenshot of the setup of the flow.
Would you mind sharing how your flow is looking?
Do you use persistent context storage?
Look at the settings.js for contextStorage
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.