Skip to content

Commit

Permalink
New Components - home_connect (PipedreamHQ#10761)
Browse files Browse the repository at this point in the history
* home_connect init

* Added actions

* Fixed changes
  • Loading branch information
lcaresia committed Mar 13, 2024
1 parent d147afb commit 09fbb75
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 8 deletions.
19 changes: 19 additions & 0 deletions components/home_connect/actions/get-appliances/get-appliances.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import app from "../../home_connect.app.mjs";

export default {
key: "home_connect-get-appliances",
name: "Get Home Appliances",
description: "Retrieves a list of paired home appliances. [See the documentation](https://apiclient.home-connect.com/#/appliances/get_home_appliances)",
version: "0.0.1",
type: "action",
props: {
app,
},
async run({ $ }) {
const response = await this.app.getAppliances($);

$.export("$summary", "Successfully retrieved paired home appliances");

return response;
},
};
28 changes: 28 additions & 0 deletions components/home_connect/actions/get-programs/get-programs.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import app from "../../home_connect.app.mjs";

export default {
key: "home_connect-get-programs",
name: "Get Available Programs",
description: "Get a list of available programs of a home appliance. [See the documentation](https://api-docs.home-connect.com/programs-and-options/#cleaning-robot_cleaning-mode-option)",
version: "0.0.1",
type: "action",
props: {
app,
haId: {
propDefinition: [
app,
"haId",
],
},
},
async run({ $ }) {
const response = await this.app.getAvailablePrograms({
$,
haId: this.haId,
});

$.export("$summary", `Successfully retrieved available programs for appliance ${this.haId}`);

return response;
},
};
28 changes: 28 additions & 0 deletions components/home_connect/actions/get-status/get-status.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import app from "../../home_connect.app.mjs";

export default {
key: "home_connect-get-status",
name: "Get Home Appliance Status",
description: "Gets the status information of a home appliance. [See the documentation](https://api-docs.home-connect.com/general/#best-practices)",
version: "0.0.1",
type: "action",
props: {
app,
haId: {
propDefinition: [
app,
"haId",
],
},
},
async run({ $ }) {
const response = await this.app.getApplianceStatus({
$,
haId: this.haId,
});

$.export("$summary", `Successfully retrieved the status of the home appliance with ID ${this.haId}`);

return response;
},
};
65 changes: 60 additions & 5 deletions components/home_connect/home_connect.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,66 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "home_connect",
propDefinitions: {},
propDefinitions: {
haId: {
type: "string",
label: "Home Appliance ID",
description: "The unique identifier of the home appliance.",
async options() {
const { data: { homeappliances: resources } } = await this.getAppliances();

return resources.map(({
haId, name,
}) => ({
value: haId,
label: name,
}));
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return `https://${this.$auth.host_environment}/api`;
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
},
});
},
async getAppliances(args = {}) {
return this._makeRequest({
path: "/homeappliances",
...args,
});
},
async getApplianceStatus({
haId, ...args
}) {
return this._makeRequest({
path: `/homeappliances/${haId}/status`,
...args,
});
},
async getAvailablePrograms({
haId, ...args
}) {
return this._makeRequest({
path: `/homeappliances/${haId}/programs/available`,
...args,
});
},
},
};
};
7 changes: 5 additions & 2 deletions components/home_connect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/home_connect",
"version": "0.0.1",
"version": "0.1.0",
"description": "Pipedream Home Connect Components",
"main": "home_connect.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^1.6.0"
}
}
}
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 09fbb75

Please sign in to comment.