Skip to content

Commit

Permalink
Fixed error in rolling prices
Browse files Browse the repository at this point in the history
  • Loading branch information
zinen committed Oct 18, 2024
1 parent e33274d commit 7f38ec7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions nordpool-api-plus.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = function (RED) {
let date = new Date()
if (node.action === 'dayAhead') {
date = new Date(date.setDate(date.getDate() + 1))
} else if (msg.date) {
} else if (node.action !== 'rolling' && msg.date) {
try {
date = new Date(msg.date)
} catch (error) {
Expand All @@ -40,13 +40,14 @@ module.exports = function (RED) {
date = new Date(date.setDate(date.getDate() - 1))
try {
opts.date = date.getFullYear() + '-' + String(date.getMonth() + 1).padStart(2, '0') + '-' + String(date.getDate()).padStart(2, '0')
// Pre append yesterdays data to array
msg.payload = (await prices(node, fetch, opts)).concat(msg.payload)
} catch (error) {
done(error.message)
return
}
date = new Date()
date = new Date(date.setDate(date.getDate() + 2))
date = new Date(date.setDate(date.getDate() + 1))
try {
opts.date = date.getFullYear() + '-' + String(date.getMonth() + 1).padStart(2, '0') + '-' + String(date.getDate()).padStart(2, '0')
msg.payload = msg.payload.concat(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-nordpool-api-plus",
"version": "4.5.3",
"version": "4.5.4",
"description": "A Node-Red Node for collecting `day ahead` prices from Nord Pool Group.",
"keywords": [
"node-red",
Expand Down

0 comments on commit 7f38ec7

Please sign in to comment.