var priceArray = [];
priceArray = flow.get(“pArray”);
const today = new Date();
let todayHour = today.getHours();
let todayDate = (“0” + today.getDate()).slice(-2)
let todayMonth = (“0” + (today.getMonth() + 1)).slice(-2);
let todayYear = today.getFullYear();
msg.payload = {
“day_ahead_price”: priceArray[todayHour] / 1000,
“avg_price”: priceArray[24] / 1000,
“max_price”: priceArray[25] / 1000,
“min_price”: priceArray[26] / 1000,
“records”: [
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T00:00:00”,
“Price”: priceArray[0] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T01:00:00”,
“Price”: priceArray[1] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T02:00:00”,
“Price”: priceArray[2] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T03:00:00”,
“Price”: priceArray[3] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T04:00:00”,
“Price”: priceArray[4] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T05:00:00”,
“Price”: priceArray[5] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T06:00:00”,
“Price”: priceArray[6] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T07:00:00”,
“Price”: priceArray[7] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T08:00:00”,
“Price”: priceArray[8] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T09:00:00”,
“Price”: priceArray[9] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T10:00:00”,
“Price”: priceArray[10] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T11:00:00”,
“Price”: priceArray[11] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T12:00:00”,
“Price”: priceArray[12] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T13:00:00”,
“Price”: priceArray[13] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T14:00:00”,
“Price”: priceArray[14] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T15:00:00”,
“Price”: priceArray[15] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T16:00:00”,
“Price”: priceArray[16] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T17:00:00”,
“Price”: priceArray[17] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T18:00:00”,
“Price”: priceArray[18] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T19:00:00”,
“Price”: priceArray[19] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T20:00:00”,
“Price”: priceArray[20] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T21:00:00”,
“Price”: priceArray[21] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T22:00:00”,
“Price”: priceArray[22] / 1000
},
{
“Time”: todayYear + “-” + todayMonth + “-” + todayDate + “T23:00:00”,
“Price”: priceArray[23] / 1000
}
]
};
return msg;
|