Preise von aWATTar abfragen

Dieser Flow ruft die Preise der kommenden 24 Stunden von der aWATTar-API ab und stellt sie grafisch in einem Balkendiagramm dar. Außerdem stellt er sie in einem Array zur weiteren Verarbeitung zur Verfügung.

[{"id":"a64b091a.a1bf2","type":"tab","label":"aWATTar","disabled":false,"info":""},{"id":"8b5f6c04.3b618","type":"http request","z":"a64b091a.a1bf2","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://api.awattar.de/v1/marketdata","tls":"","persist":false,"proxy":"","authType":"","x":330,"y":340,"wires":[["192872f5.e2d8fd"]]},{"id":"d14916ff.24eb98","type":"inject","z":"a64b091a.a1bf2","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":130,"y":340,"wires":[["8b5f6c04.3b618"]]},{"id":"b55ac867.5e8d18","type":"debug","z":"a64b091a.a1bf2","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":630,"y":400,"wires":[]},{"id":"192872f5.e2d8fd","type":"json","z":"a64b091a.a1bf2","name":"","property":"payload","action":"","pretty":false,"x":490,"y":340,"wires":[["c45ef36c.746fb"]]},{"id":"c45ef36c.746fb","type":"split","z":"a64b091a.a1bf2","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":120,"y":400,"wires":[["4df30205.32ac34","e155a845.29cf58"]]},{"id":"4df30205.32ac34","type":"split","z":"a64b091a.a1bf2","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":340,"y":400,"wires":[["e43d0284.cb377"]]},{"id":"e43d0284.cb377","type":"switch","z":"a64b091a.a1bf2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"object","vt":"object"}],"checkall":"true","repair":false,"outputs":1,"x":470,"y":400,"wires":[["b55ac867.5e8d18"]]},{"id":"673642ac.a881a4","type":"comment","z":"a64b091a.a1bf2","name":"aWATTar abfragen","info":"","x":450,"y":260,"wires":[]},{"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":[["8b5f6c04.3b618"]]},{"id":"2653648a.b6dbac","type":"function","z":"a64b091a.a1bf2","name":"","func":"message = msg.payload;\nvar daten = [];\nvar stunden = [];\nvar preise = [];\n\nfor(i = 0; i<message.length; i++){\n    hour = new Date(message[i].start_timestamp);\n    stunde = hour.getHours();\n    price = message[i].marketprice/10;\n    \n    daten.push([price, hour]);\n    stunden.push(stunde);\n    preise.push(price);\n}\n\nbargraph = [{\n    \"series\": [\"\"],\n    \"data\": [preise],\n    \"labels\": stunden\n}];\n\nreturn [{payload: daten}, {payload: bargraph}];\n","outputs":2,"noerr":0,"initialize":"","finalize":"","x":340,"y":460,"wires":[["a0bdf391.90198"],["4818bed5.a4f23","c776b0f.8d51dd"]]},{"id":"e155a845.29cf58","type":"switch","z":"a64b091a.a1bf2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"istype","v":"array","vt":"array"}],"checkall":"true","repair":false,"outputs":1,"x":110,"y":460,"wires":[["2653648a.b6dbac"]]},{"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":false,"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}]

Flow Info

Created 3 years, 11 months ago
Rating: 5 1

Owner

Actions

Rate:

Node Types

Core
  • comment (x1)
  • debug (x3)
  • function (x1)
  • http request (x1)
  • inject (x1)
  • json (x1)
  • split (x2)
  • switch (x2)
Other
  • tab (x1)
  • ui_button (x1)
  • ui_chart (x1)
  • ui_group (x1)
  • ui_tab (x1)

Tags

  • awattar
  • api
  • graph
  • diagramm
  • balkendiagramm
  • strompreis
  • energie
  • energy
  • stromkosten
  • strom
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option