I’ve spent a bit of time setting up a Node-RED flow to import prices from my (unsupported) local provider in Australia - Amber Electric - using their API. With thanks to @dfaber’s post and @podarok’s contribution also, I’m feeding the provider’s prices into Dynamic ESS successfully:
// Extract the intervals from the payload
const intervals = msg.payload;
// Create empty arrays to hold buy and sell schedules
let buySchedule = [];
let sellSchedule = [];
// Helper function to convert UTC time to local time
const toLocalTime = (isoTime) => {
const date = new Date(isoTime);
const options = {
hour: '2-digit',
minute: '2-digit',
hour12: false,
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone // Local timezone
};
let time = new Intl.DateTimeFormat('en-US', options).format(date);
// Fix for midnight time formatting
if (time.startsWith("24:")) {
time = time.replace("24:", "00:");
}
return time;
};
// Iterate through each interval and sort data into buy and sell schedules
intervals.forEach(interval => {
const from = toLocalTime(interval.startTime); // Convert to local time
const to = toLocalTime(interval.endTime); // Convert to local time
// Extract and format price
let price = parseFloat(interval.perKwh);
if (interval.channelType === "general") {
// Convert buy price to dollars and round to the nearest cent
price = Math.round(price) / 100;
buySchedule.push({ from: from, to: to, price: price });
} else if (interval.channelType === "feedIn") {
// Invert sell price, convert to dollars, and round to the nearest cent
price = Math.round(-price) / 100;
sellSchedule.push({ from: from, to: to, price: price });
}
});
// Create the final output structure
const buyPriceSchedule = [{
days: [0, 1, 2, 3, 4, 5, 6], // All days of the week
schedule: buySchedule
}];
const sellPriceSchedule = [{
days: [0, 1, 2, 3, 4, 5, 6], // All days of the week
schedule: sellSchedule
}];
// Assign the formatted schedules to the payload
msg.payload = {
buyPriceSchedule: JSON.stringify(buyPriceSchedule),
sellPriceSchedule: JSON.stringify(sellPriceSchedule)
};
return msg;
This function node feeds a “Change Dynamic ESS Settings” node, which successfully imports the price data from my provider.
If I look at VRM → Settings → Dynamic ESS, I see the buy and sell prices correlating correctly to the information my electricity provider’s API generated. What doesn’t line up, though, is the graphed “Schedule” data in the Dynamic ESS section of the dashboard - the prices are not what has been specified on the Dynamic ESS settings page by the Node-RED.
I confess I don’t understand Dynamic ESS well enough just yet - I’m really just experimenting at the moment and it’s switched off for now because it hasn’t been making good decisions - but I’m concerned that it’s not acting on up-to-date information based on the discrepancy between the graph and the settings page.
My provider passes on wholesale prices (our national energy market operates on a 5-minute basis), and I trigger the flow to reload every 15 minutes so as not to overwhelm the system or the provider’s API.
Does anyone have feedback about this approach and why there might be this discrepancy?
Thanks so much in advance, this is a great product that I’m sure will only get better!
Andrew