Dynamic electricity supplier output in table format

Hi, I need some help. I'm relatively new to Node-RED.

I found a flow that would be perfect for me. You can find it here:
https://flows.nodered.org/flow/df892f62326e5dce5708b7512213ce24

This flow should output the hourly prices in Brutto and in kwh from the electricity supplier "aWATTar". There is an API interface from this provider.

I was able to adapt the function, but I'm not sure if it's correct. Here's the code I'm using:

let message = msg.payload;
let i;
let hour;
let stunde;
let price;
let bargraph;


var daten = [];
var stunden = [];
var preise = [];

for(i = 0; i <message.length; i++)
{
  let marketprice = message[i].marketprice;

  hour = new Date(message[i].start_timestamp);
  stunde = hour.getHours();
  price = marketprice;

  daten.push([price, hour]);
  stunden.push(stunde);
  preise.push(price);
}

bargraph = [
{
  "series": [""],
  "data": [preise],
  "labels": stunden
}];

return [{payload: daten}, {payload: bargraph}];

The output I get never looks exactly like what I see on this URL:

I would like to have what this URL shows in Brutto, represented in bars.

Thank you very much.

BR K-ist-K

Hi, what exactly is the issue can you show images of the aWATTer site bar chart and your dash board bar chart. Then describe what is not right. As only difference i see is style and bar chart start time.


At first, in node-red i have mwh not kwh (no problem Value / 10)
Node-Red:
21: 105,03
22: 97,07
23: 101,61
00: 96,30
01: 102,55
02: 96,00

aWATTar
21: 10,47 kwh (104,70)
22: 10,50 kwh (105,00)
23: 9,71 kwh (97,10)
00: 10,16 kwh (101,60)
01: 9,63 kwh (96,30)
02: 10,25 kwh (102,50)

I see, my node-red run 1 hour too late.
But the value's are not correct.
I think it is not a Node-Red Problem.

Can i change the chart, that i see in the chart the value per Hour?
Like by aWATTar?

Looks like the api is returning 9am to midnight the 1 am to 8 am next day.

While the website is returning midnight to 11 pm, all one day.

Try using the https://api.awattar.at/v1/marketdata?start=1561932000000 api url and feeding in a start time at midnight
e.g.

[{"id":"d14916ff.24eb98","type":"inject","z":"a64b091a.a1bf2","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":340,"wires":[["8ffd441bdc02b8f8"]]},{"id":"8ffd441bdc02b8f8","type":"change","z":"a64b091a.a1bf2","name":"","rules":[{"t":"set","p":"time","pt":"msg","to":"$moment($moment().utc().format(\"YYYY-MM-DD\")).format(\"x\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":310,"y":280,"wires":[["8b5f6c04.3b618"]]},{"id":"6f444514.b1f43c","type":"ui_button","z":"a64b091a.a1bf2","name":"","group":"1495fa22.b16436","order":1,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"","payloadType":"str","topic":"","x":150,"y":300,"wires":[["8ffd441bdc02b8f8"]]},{"id":"8b5f6c04.3b618","type":"http request","z":"a64b091a.a1bf2","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.awattar.at/v1/marketdata?start={{time}}","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":330,"y":340,"wires":[["2653648a.b6dbac"]]},{"id":"2653648a.b6dbac","type":"function","z":"a64b091a.a1bf2","name":"","func":"let message = msg.payload.data;\nlet i;\nlet hour;\nlet stunde;\nlet price;\nlet bargraph;\n\n\nvar daten = [];\nvar stunden = [];\nvar preise = [];\n\nfor(i = 0; i <message.length; i++)\n{\n  let marketprice = message[i].marketprice;\n\n  hour = new Date(message[i].start_timestamp);\n  stunde = hour.getHours();\n  price = marketprice;\n\n  daten.push([price, hour]);\n  stunden.push(stunde);\n  preise.push(price);\n}\n\nbargraph = [\n{\n  \"series\": [\"\"],\n  \"data\": [preise],\n  \"labels\": stunden\n}];\n\nreturn [{payload: daten}, {payload: bargraph}];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":340,"y":460,"wires":[["a0bdf391.90198"],["4818bed5.a4f23","c776b0f.8d51dd"]]},{"id":"a0bdf391.90198","type":"debug","z":"a64b091a.a1bf2","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":460,"wires":[]},{"id":"4818bed5.a4f23","type":"debug","z":"a64b091a.a1bf2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":610,"y":500,"wires":[]},{"id":"c776b0f.8d51dd","type":"ui_chart","z":"a64b091a.a1bf2","name":"","group":"1495fa22.b16436","order":1,"width":0,"height":0,"label":"ct/kWh","chartType":"bar","legend":"false","xformat":"auto","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":true,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"outputs":1,"useDifferentColor":false,"x":620,"y":540,"wires":[[]]},{"id":"1495fa22.b16436","type":"ui_group","name":"Standard","tab":"f420fdaa.3226a8","order":1,"disp":true,"width":"20","collapse":false},{"id":"f420fdaa.3226a8","type":"ui_tab","name":"aWATTar","icon":"dashboard","disabled":false,"hidden":false}]

other urls

1 Like

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