Skip to content

Commit 85d818c

Browse files
authored
New Components - solcast (#15513)
* new components * pnpm-lock.yaml
1 parent b399c80 commit 85d818c

File tree

6 files changed

+221
-8
lines changed

6 files changed

+221
-8
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import solcast from "../../solcast.app.mjs";
2+
3+
export default {
4+
key: "solcast-get-live-weather",
5+
name: "Get Live Weather",
6+
description: "Get irradiance and weather estimated actuals for near real-time and past 7 days for the requested location, derived from satellite and numerical weather models. [See the documentation](https://docs.solcast.com.au/#b9863910-c788-4e98-a3af-eb8da8f49647)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
solcast,
11+
latitude: {
12+
propDefinition: [
13+
solcast,
14+
"latitude",
15+
],
16+
},
17+
longitude: {
18+
propDefinition: [
19+
solcast,
20+
"longitude",
21+
],
22+
},
23+
hours: {
24+
propDefinition: [
25+
solcast,
26+
"hours",
27+
],
28+
},
29+
period: {
30+
propDefinition: [
31+
solcast,
32+
"period",
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.solcast.getLiveWeather({
38+
$,
39+
params: {
40+
latitude: this.latitude,
41+
longitude: this.longitude,
42+
hours: this.hours,
43+
period: this.period,
44+
},
45+
});
46+
$.export("$summary", `Successfully retrieved live weather data for location \`${this.latitude}, ${this.longitude}\``);
47+
return response;
48+
},
49+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import solcast from "../../solcast.app.mjs";
2+
3+
export default {
4+
key: "solcast-get-monthly-averages",
5+
name: "Get Monthly Averages",
6+
description: "Get montly weather averages for a location. [See the documentation](https://docs.solcast.com.au/#7ad3c227-d385-4455-b17f-3efcb8d4c695)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
solcast,
11+
latitude: {
12+
propDefinition: [
13+
solcast,
14+
"latitude",
15+
],
16+
},
17+
longitude: {
18+
propDefinition: [
19+
solcast,
20+
"longitude",
21+
],
22+
},
23+
timezone: {
24+
type: "string",
25+
label: "Timezone",
26+
description: "Date time to return in data set. Accepted values are `utc`, `longitudinal`, or a range `-13` to `13` for utc offset.",
27+
optional: true,
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.solcast.getMonthlyAverages({
32+
$,
33+
params: {
34+
latitude: this.latitude,
35+
longitude: this.longitude,
36+
timezone: this.timezone,
37+
},
38+
});
39+
$.export("$summary", `Successfully retrieved monthly averages for location \`${this.latitude}, ${this.longitude}\``);
40+
return response;
41+
},
42+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import solcast from "../../solcast.app.mjs";
2+
3+
export default {
4+
key: "solcast-get-weather-forecast",
5+
name: "Get Weather Forecast",
6+
description: "Get irradiance and weather forecasts for the requested location from the present up to 14 days ahead, derived from satellite and numerical weather models. [See the documentation](https://docs.solcast.com.au/#4e0e8a96-7a12-4654-8407-6bbbb37478b1)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
solcast,
11+
latitude: {
12+
propDefinition: [
13+
solcast,
14+
"latitude",
15+
],
16+
},
17+
longitude: {
18+
propDefinition: [
19+
solcast,
20+
"longitude",
21+
],
22+
},
23+
hours: {
24+
propDefinition: [
25+
solcast,
26+
"hours",
27+
],
28+
},
29+
period: {
30+
propDefinition: [
31+
solcast,
32+
"period",
33+
],
34+
},
35+
},
36+
async run({ $ }) {
37+
const response = await this.solcast.getWeatherForecast({
38+
$,
39+
params: {
40+
latitude: this.latitude,
41+
longitude: this.longitude,
42+
hours: this.hours,
43+
period: this.period,
44+
},
45+
});
46+
$.export("$summary", `Successfully retrieved forecast data for location \`${this.latitude}, ${this.longitude}\``);
47+
return response;
48+
},
49+
};

components/solcast/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/solcast",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Solcast Components",
55
"main": "solcast.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

components/solcast/solcast.app.mjs

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,75 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "solcast",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
latitude: {
8+
type: "string",
9+
label: "Latitude",
10+
description: "The latitude of the location",
11+
},
12+
longitude: {
13+
type: "string",
14+
label: "Longitude",
15+
description: "The longitude of the location",
16+
},
17+
hours: {
18+
type: "integer",
19+
label: "Hours",
20+
description: "Time window of the response in hours from 1 to 336",
21+
max: 336,
22+
optional: true,
23+
},
24+
period: {
25+
type: "string",
26+
label: "Period",
27+
description: "Length of the averaging period in ISO 8601 format. Default is `PT30M`",
28+
options: [
29+
"PT5M",
30+
"PT10M",
31+
"PT15M",
32+
"PT20M",
33+
"PT30M",
34+
"PT60M",
35+
],
36+
optional: true,
37+
},
38+
},
539
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
40+
_baseUrl() {
41+
return "https://api.solcast.com.au";
42+
},
43+
_makeRequest({
44+
$ = this,
45+
path,
46+
...opts
47+
}) {
48+
return axios($, {
49+
url: `${this._baseUrl()}${path}`,
50+
headers: {
51+
Authorization: `Bearer ${this.$auth.api_key}`,
52+
},
53+
...opts,
54+
});
55+
},
56+
getLiveWeather(opts = {}) {
57+
return this._makeRequest({
58+
path: "/data/live/radiation_and_weather",
59+
...opts,
60+
});
61+
},
62+
getWeatherForecast(opts = {}) {
63+
return this._makeRequest({
64+
path: "/data/forecast/radiation_and_weather",
65+
...opts,
66+
});
67+
},
68+
getMonthlyAverages(opts = {}) {
69+
return this._makeRequest({
70+
path: "/monthly_averages",
71+
...opts,
72+
});
973
},
1074
},
11-
};
75+
};

pnpm-lock.yaml

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)