So, i'm building a powerwall!

The current energy prices are fluctuating by the hour based on the EPEX price.
I am building a powerwall to store the cheap energy, and sell back to the grid when prices are high.

Ofcourse i want to automate that, and that’s exactly my problem…

In the community i found some similair post like this one:

and this one

but it is not exactly what i am looking for.
I need a sensor, telling me if if the inverter needs to charge, be idle or discharge, based on the current electricity prices. For example: The 4 “cheapest” hours it will charge, the 4 most expensive hours it wil discharge, and the rest of the day the inverter will be idle.

This API gives me the information that i need, i just don’t know how to program this.
https://api.awattar.at/v1/marketdata?start=1628139600000&end=1628226000000

Is there anyone that can help me with this?
Thank you!

This:

[{"id":"05acd60063343272","type":"debug","z":"ad594fb84fe6d294","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":400,"wires":[]},{"id":"e27094188bd734b2","type":"function","z":"ad594fb84fe6d294","name":"","func":"msg.marketprice = msg.payload.data.map(function(value,index) { return  value[\"marketprice\"]; });\nmsg.marketprice2 = msg.payload.data.map(function(value,index) { return  value[\"marketprice\"]; });\nmsg.start_timestamp = msg.payload.data.map(function(value,index) { return  value[\"start_timestamp\"]; });\n\n\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":440,"wires":[["bb48fc85f7462c50"]]},{"id":"1865a4c5166af79c","type":"inject","z":"ad594fb84fe6d294","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":170,"y":440,"wires":[["97db34ca55db5761"]]},{"id":"97db34ca55db5761","type":"http request","z":"ad594fb84fe6d294","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://api.awattar.at/v1/marketdata?start=1628139600000&end=1628226000000","tls":"","persist":false,"proxy":"","authType":"","senderr":false,"x":330,"y":540,"wires":[["e27094188bd734b2"]]},{"id":"bb48fc85f7462c50","type":"sort","z":"ad594fb84fe6d294","name":"","order":"ascending","as_num":false,"target":"marketprice","targetType":"msg","msgKey":"payload","msgKeyType":"elem","seqKey":"payload","seqKeyType":"msg","x":670,"y":420,"wires":[["973cc63cc2d3bd17"]]},{"id":"973cc63cc2d3bd17","type":"function","z":"ad594fb84fe6d294","name":"","func":"var cheap = {};\nvar expensive = {};\n\nfor( var index in msg.marketprice){\n    \n    if (index <=3){\n        found = msg.marketprice2.indexOf(msg.marketprice[index]);\n        if (found > -1) {\n            cheap[msg.start_timestamp[found]] = msg.marketprice[index];    \n        }\n    }else if (index >= 20){\n        found = msg.marketprice2.indexOf(msg.marketprice[index]);\n        if (found > -1) {\n            expensive[msg.start_timestamp[found]] = msg.marketprice[index];    \n        }\n    }\n}\n\nmsg.expensive = expensive;\nmsg.cheap = cheap;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":840,"y":420,"wires":[["05acd60063343272"]]}]

gives you two objects

with the start times of cheap or expensive times.

1 Like

Thank you! That’s it! didn’t know it was this simple!

Please excuse my dumb question - but where do I paste this code?
Node Red? Modbus? Yaml?

Thank You!!!

Yes Node red.
Hamburger → import

1 Like

Thank You!!