forked from PipedreamHQ/pipedream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Components - home_connect (PipedreamHQ#10761)
* home_connect init * Added actions * Fixed changes
- Loading branch information
Showing
6 changed files
with
144 additions
and
8 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
components/home_connect/actions/get-appliances/get-appliances.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
28
components/home_connect/actions/get-programs/get-programs.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}); | ||
}, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.