-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (50 loc) · 1.91 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import GetCarbonData from "./getCarbonData.js";
import { GetCurrentDate } from "./GetCurrentDate.js";
import getFutureEnergyData from "./getSolarWindData.js";
import SendLoad from "./SendLoad.js";
const PackageData = async () => {
console.info(`--------------------------------`);
console.info(`Timestamp: ${GetCurrentDate()}`)
console.info(`Collecting Data...`)
let CarbonData = await GetCarbonData();
let SolarWindData = await getFutureEnergyData();
let dataPacket = {
TimeStamp: new Date(),
data: {
CarbonIntensityData: {
TimeStamp: CarbonData["datetime"],
"East Midlands": CarbonData["East Midlands"],
"East England": CarbonData["East England"],
"West Midlands": CarbonData["West Midlands"],
"North Scotland": CarbonData["North Scotland"],
"South Scotland": CarbonData["South Scotland"],
"South West England": CarbonData["South West England"],
"North Wales and Merseyside": CarbonData["North Wales and Merseyside"],
"North East England": CarbonData["North East England"],
"South East England": CarbonData["South East England"],
"South Wales": CarbonData["South Wales"],
"North West England": CarbonData["North West England"],
Yorkshire: CarbonData["Yorkshire"],
London: CarbonData["London"],
"South England": CarbonData["South England"],
},
Solar: {
TimeStamp: SolarWindData["TIME_GMT"],
Solar_Forecast: SolarWindData["EMBEDDED_WIND_FORECAST"],
Solar_Capacity: SolarWindData["EMBEDDED_WIND_CAPACITY"],
},
Wind: {
TimeStamp: SolarWindData["TIME_GMT"],
Wind_Forecast: SolarWindData["EMBEDDED_WIND_FORECAST"],
Wind_Capacity: SolarWindData["EMBEDDED_WIND_CAPACITY"],
},
},
};
return dataPacket;
};
(async () => {
SendLoad(await PackageData());
})();
setInterval(async () => {
SendLoad(await PackageData());
}, 1800000);