-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from pbrosi-sag/master
webmethods-io example custom connector for home automation
- Loading branch information
Showing
22 changed files
with
861 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
NetatmoSecurity/node_modules/ |
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 @@ | ||
{"service_name":"NetatmoSecurity_fl91ccd279ad5dcd19d902bc"} |
76 changes: 76 additions & 0 deletions
76
netatmo-security-connector/NetatmoSecurity/action/v1/gethomedata.js
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,76 @@ | ||
module.exports = { | ||
|
||
name: "gethomedata", | ||
|
||
title: "Gethomedata", | ||
|
||
description: "", | ||
version: "v1", | ||
|
||
input:{ | ||
title: "Gethomedata", | ||
type: "object", | ||
properties: { | ||
home_id :{ | ||
title: "home_id", | ||
displayTitle: "Home ID", | ||
type: "string" | ||
} | ||
} | ||
}, | ||
|
||
output: { | ||
title: "output", | ||
type: "object", | ||
displayTitle: "Output", | ||
properties: { | ||
|
||
} | ||
}, | ||
|
||
mock_input:{}, | ||
|
||
execute: function(input, output){ | ||
// to access auth info use input.auth , eg: input.auth.username | ||
// and to return output use output callback like this output(null, { 'notice' : 'successful'}) | ||
// your code here | ||
// output(null, { data : "OK"}); | ||
var request = require("request"); | ||
|
||
var options = { | ||
"method": "get", | ||
"url": "https://api.netatmo.com/api/gethomedata", | ||
"headers": { | ||
"Accept": "application/json", | ||
"Authorization": "Bearer " + input.auth.access_token | ||
} | ||
} | ||
request(options, function(err, response, body) { | ||
if (err) { | ||
return output(err); | ||
} | ||
try { | ||
if (body && typeof(body) === "string") { | ||
body = JSON.parse(body); | ||
} | ||
} catch (e) { | ||
return output(body); | ||
}; | ||
if (response.statusCode === 401) { | ||
return output("Invalid access token"); | ||
} | ||
if (response.statusCode !== 200) { | ||
return output("Error Details"); | ||
} | ||
if (response.statusCode === 200) { | ||
return output(null, body); | ||
} | ||
output(body); | ||
|
||
}) | ||
|
||
|
||
|
||
} | ||
|
||
} |
77 changes: 77 additions & 0 deletions
77
netatmo-security-connector/NetatmoSecurity/action/v1/gethomestatus.js
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,77 @@ | ||
module.exports = { | ||
|
||
name: "gethomestatus", | ||
|
||
title: "Gethomestatus", | ||
|
||
description: "", | ||
version: "v1", | ||
|
||
input:{ | ||
title: "Gethomestatus", | ||
type: "object", | ||
properties: { | ||
home_id :{ | ||
title: "home_id", | ||
displayTitle: "Home ID", | ||
type: "string" | ||
} | ||
} | ||
}, | ||
|
||
output: { | ||
title: "output", | ||
type: "object", | ||
displayTitle: "Output", | ||
properties: { | ||
|
||
} | ||
}, | ||
|
||
mock_input:{}, | ||
|
||
execute: function(input, output){ | ||
// to access auth info use input.auth , eg: input.auth.username | ||
// and to return output use output callback like this output(null, { 'notice' : 'successful'}) | ||
// your code here | ||
// output(null, { data : "OK"}); | ||
|
||
|
||
var request = require("request"); | ||
|
||
var options = { | ||
"method": "get", | ||
"url": "https://api.netatmo.com/api/homestatus?home_id=" + input.home_id, | ||
"headers": { | ||
"Accept": "application/json", | ||
"Authorization": "Bearer " + input.auth.access_token | ||
} | ||
} | ||
request(options, function(err, response, body) { | ||
if (err) { | ||
return output(err); | ||
} | ||
try { | ||
if (body && typeof(body) === "string") { | ||
body = JSON.parse(body); | ||
} | ||
} catch (e) { | ||
return output(body); | ||
}; | ||
if (response.statusCode === 401) { | ||
return output("Invalid access token"); | ||
} | ||
if (response.statusCode !== 200) { | ||
return output(body); | ||
} | ||
if (response.statusCode === 200) { | ||
return output(null, body); | ||
} | ||
output(body); | ||
|
||
}) | ||
|
||
|
||
} | ||
|
||
} |
83 changes: 83 additions & 0 deletions
83
netatmo-security-connector/NetatmoSecurity/action/v1/getnextevents.js
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,83 @@ | ||
module.exports = { | ||
|
||
name: "getnextevents", | ||
|
||
title: "Getnextevents", | ||
|
||
description: "", | ||
version: "v1", | ||
|
||
input:{ | ||
title: "Getnextevents", | ||
type: "object", | ||
properties: { | ||
home_id :{ | ||
title: "home_id", | ||
displayTitle: "Home ID", | ||
type: "string" | ||
}, | ||
event_id :{ | ||
title: "event_id", | ||
displayTitle: "Before this event", | ||
type: "string" | ||
}, | ||
size: { | ||
title: "size", | ||
displayTitle: "Number of events (default 30)", | ||
type: "string" | ||
} | ||
} | ||
}, | ||
|
||
output: { | ||
title: "output", | ||
type: "object", | ||
displayTitle: "Output", | ||
properties: { | ||
} | ||
}, | ||
|
||
mock_input:{}, | ||
|
||
execute: function(input, output){ | ||
// to access auth info use input.auth , eg: input.auth.username | ||
// and to return output use output callback like this output(null, { 'notice' : 'successful'}) | ||
// your code here | ||
|
||
var request = require("request"); | ||
|
||
var options = { | ||
"method": "get", | ||
"url": "https://api.netatmo.com/api/getnextevents?home_id=" + input.home_id + "&event_id=" + input.event_id + "&size=" + input.size, | ||
"headers": { | ||
"Accept": "application/json", | ||
"Authorization": "Bearer " + input.auth.access_token | ||
} | ||
} | ||
request(options, function(err, response, body) { | ||
if (err) { | ||
return output(err); | ||
} | ||
try { | ||
if (body && typeof(body) === "string") { | ||
body = JSON.parse(body); | ||
} | ||
} catch (e) { | ||
return output(body); | ||
}; | ||
if (response.statusCode === 401) { | ||
return output("Invalid access token"); | ||
} | ||
if (response.statusCode !== 200) { | ||
return output(body); | ||
} | ||
if (response.statusCode === 200) { | ||
return output(null, body); | ||
} | ||
output(body); | ||
|
||
}) | ||
|
||
} | ||
|
||
} |
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,4 @@ | ||
{ | ||
"username": "<username>", | ||
"password": "<password>" | ||
} |
13 changes: 13 additions & 0 deletions
13
netatmo-security-connector/NetatmoSecurity/authentication.js
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,13 @@ | ||
module.exports = { | ||
label: "Connect to NetatmoSecurity", | ||
mock_input: { | ||
access_token: "" | ||
}, | ||
oauth: "netatmo_camera_4a4b969c20", | ||
validate: function (input, output) { | ||
// auth credentials will be available in input.auth.access_token | ||
// callback pattern | ||
// output(error, success) | ||
output(null, true) | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,17 @@ | ||
{ | ||
"name": "NetatmoSecurity", | ||
"description": "Netatmo Security Camera connector", | ||
"triggers": [], | ||
"actions": [ | ||
"/v1/gethomedata", | ||
"/v1/gethomestatus", | ||
"/v1/getnextevents" | ||
], | ||
"version": 1, | ||
"auth_type": "oauth", | ||
"docs_link": "http://docs.example.com", | ||
"oauth_provider": "netatmo_camera_4a4b969c20", | ||
"oauthStatus": "deployed", | ||
"appId": "44e90f51-9b6c-4651-a22a-bf756bf0adce", | ||
"guid": "8be1585c-a8c5-4d57-9b1d-fc3780d6cc69" | ||
} |
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,51 @@ | ||
{ | ||
"type": "oauth2", | ||
"title": "netatmo_camera", | ||
"clientId": "<clientID>", | ||
"clientSecret": "<secret>", | ||
"authURL": "https://api.netatmo.com/oauth2/authorize", | ||
"tokenURL": "https://api.netatmo.com/oauth2/token", | ||
"preAuthProcessing": { | ||
}, | ||
"authQueryParams": { | ||
"state": "ab82aff8dd2caf097e6", | ||
"scope": "read_camera" | ||
}, | ||
|
||
"preTokenProcessing": { | ||
}, | ||
|
||
"tokenParams": { | ||
"method": "", | ||
"headers": {}, | ||
"data": { | ||
"client_id": "{client_id}", | ||
"client_secret": "{client_secret}", | ||
"redirect_uri": "{redirect_uri}", | ||
"grant_type": "authorization_code" | ||
} | ||
}, | ||
"preRefreshProcessing": { | ||
}, | ||
"refreshParams": { | ||
"client_id": "{client_id}", | ||
"client_secret": "{client_secret}", | ||
"redirect_uri": "{redirect_uri}", | ||
"grant_type": "refresh_token" | ||
}, | ||
"requiredParams": [ | ||
], | ||
"refreshURL": "{tokenURL}", | ||
"scope": { | ||
"Read Camera Scope": "read_camera" | ||
}, | ||
"validate": { | ||
"url": "ANY API URL TO VALIDATE TOKEN OF THIRD PARTY SERVICE", | ||
"headers": { | ||
"Authorization": "Bearer {access_token}" | ||
}, | ||
"query": { | ||
} | ||
}, | ||
"redirectURL": "https://auth-int.webmethods.io/auth/oauth/netatmo_camera_4a4b969c20/fl91ccd279ad5dcd19d902bc/return" | ||
} |
Oops, something went wrong.