[{"id":"de5c7e3d3db84874","type":"tab","label":"EPEX SPOT","disabled":false,"info":""},{"id":"83d766dddcdc5d92","type":"inject","z":"de5c7e3d3db84874","name":"Current Timestamp","props":[{"p":"timestamp","v":"","vt":"date"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":"5","topic":"","x":150,"y":80,"wires":[["406057342cbce9fe"]]},{"id":"dae5e019e5311d7a","type":"html","z":"de5c7e3d3db84874","name":"Extract hours","property":"payload","outproperty":"hours","tag":".js-table-times .child","ret":"text","as":"single","x":330,"y":200,"wires":[["95eb8c166e2e63a0"]]},{"id":"9aaee25ea57b3a6b","type":"moment","z":"de5c7e3d3db84874","name":"Today","topic":"Today","input":"timestamp","inputType":"msg","inTz":"Europe/Berlin","adjAmount":"1","adjType":"days","adjDir":"subtract","format":"YYYY-MM-DD","locale":"C","output":"trading_date","outputType":"msg","outTz":"Europe/Berlin","x":550,"y":80,"wires":[["97a70636db3f3223"]]},{"id":"899c503bf63c9d97","type":"debug","z":"de5c7e3d3db84874","name":"Today","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":970,"y":460,"wires":[]},{"id":"97a70636db3f3223","type":"moment","z":"de5c7e3d3db84874","name":"Tomorrow","topic":"Tomorrow","input":"timestamp","inputType":"msg","inTz":"Europe/Berlin","adjAmount":"0","adjType":"hours","adjDir":"add","format":"YYYY-MM-DD","locale":"C","output":"delivery_date","outputType":"msg","outTz":"Europe/Berlin","x":700,"y":80,"wires":[["562ec0691243c815"]]},{"id":"562ec0691243c815","type":"change","z":"de5c7e3d3db84874","name":"","rules":[{"t":"set","p":"url","pt":"msg","to":"\"https://www.epexspot.com/\" & \t\"en/market-data\" & \t\"?market_area=DE-LU\" & \t\"&trading_date=\" & msg.trading_date &\t\"&delivery_date=\" & msg.delivery_date &\t\"&underlying_year=\" & \t\"&modality=Auction\" & \t\"&sub_modality=DayAhead\" &\t\"&product=60\" & \t\"&data_mode=table\" & \t\"&period=\"","tot":"jsonata"},{"t":"delete","p":"payload","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":890,"y":80,"wires":[["e90f11830782987b"]]},{"id":"e90f11830782987b","type":"www-request","z":"de5c7e3d3db84874","name":"Get EPEX page","method":"GET","ret":"txt","url":"","follow-redirects":true,"persistent-http":true,"tls":"","x":140,"y":200,"wires":[["dae5e019e5311d7a"]]},{"id":"95eb8c166e2e63a0","type":"html","z":"de5c7e3d3db84874","name":"Extract values","property":"payload","outproperty":"values","tag":".js-table-values .child","ret":"html","as":"single","x":340,"y":260,"wires":[["625eed04f9c27741"]]},{"id":"2b5564df4fd40471","type":"function","z":"de5c7e3d3db84874","name":"Split TableInfo","func":"msg.buyvolume = [];\nmsg.sellvolume = [];\nmsg.volume = [];\nmsg.price = [];\n\nmsg.payload = null;\n\nfor(let i = 0; i < msg.tmp.table.tr.length; i++) {\n    \n    var atr = msg.tmp.table.tr[i];\n    var td0 = atr.td[0].replace(',','');\n    var td1 = atr.td[1].replace(',','');\n    var td2 = atr.td[2].replace(',','');\n    var td3 = atr.td[3].replace(',','');\n    \n    msg.buyvolume.push(parseFloat(td0));\n    msg.sellvolume.push(parseFloat(td1));\n    msg.volume.push(parseFloat(td2));\n    msg.price.push(parseFloat(td3) / 10);\n}\n\nmsg.volumeUnit = \"MWh\"\nmsg.priceUnit = \"ct/kWh\"\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":540,"y":320,"wires":[["20d94b06a00d7507"]]},{"id":"625eed04f9c27741","type":"function","z":"de5c7e3d3db84874","name":"Prepare XML","func":"msg.tmp = \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\\r\\n\";\nmsg.tmp += \"<table>\"\n\nfor (let i = 0; i < msg.values.length; i++) {\n    msg.tmp += \"<tr>\\r\\n\"\n    msg.tmp += msg.values[i];\n    msg.tmp += \"</tr>\\r\\n\"\n}\nmsg.tmp += \"</table>\\r\\n\"\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":530,"y":260,"wires":[["abd1b8b7977be6d4"]]},{"id":"abd1b8b7977be6d4","type":"xml","z":"de5c7e3d3db84874","name":"xml2json","property":"tmp","attr":"","chr":"","x":320,"y":320,"wires":[["2b5564df4fd40471"]]},{"id":"20d94b06a00d7507","type":"moment","z":"de5c7e3d3db84874","name":"CurrentHour","topic":"CurrentHour","input":"timestamp","inputType":"msg","inTz":"Europe/Berlin","adjAmount":"0","adjType":"days","adjDir":"add","format":"H","locale":"C","output":"currentHour","outputType":"msg","outTz":"Europe/Berlin","x":330,"y":400,"wires":[["13ce0cf5b5564e95"]]},{"id":"13ce0cf5b5564e95","type":"function","z":"de5c7e3d3db84874","name":"Extract Current","func":"var curHour = parseInt(msg.currentHour);\n\nmsg.currentVolume = msg.volume[curHour];\nmsg.currentPrice = msg.price[curHour];\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":400,"wires":[["19ed9e8db65dfaf1"]]},{"id":"19ed9e8db65dfaf1","type":"ha-entity","z":"de5c7e3d3db84874","name":"EPEX Spot Current Price","server":"fbb2f3e2.d6216","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"epex_spot_price"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":"ct/kWh"}],"state":"currentPrice","stateType":"msg","attributes":[{"property":"currentVolume","value":"currentVolume","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":780,"y":460,"wires":[["899c503bf63c9d97"]]},{"id":"406057342cbce9fe","type":"cronplus","z":"de5c7e3d3db84874","name":"Hourly","outputField":"timestamp","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"fanOut","outputs":3,"options":[{"name":"Hourly","topic":"Timestamp","payloadType":"date","payload":"","expressionType":"cron","expression":"0 0 * * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":350,"y":80,"wires":[["9aaee25ea57b3a6b"],[],[]]},{"id":"fbb2f3e2.d6216","type":"server","name":"Home Assistant","version":1,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]
