This repository has been archived by the owner on Feb 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AzureInvokeMethodOnDevice.json
25 lines (25 loc) · 2.26 KB
/
AzureInvokeMethodOnDevice.json
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
{
"name": "AzureInvokeMethodOnDevice",
"version": "0.0.5",
"type": "actuator",
"script": "const Client = require('azure-iothub').Client\n/**\n * More documentation on sending data to an Azure connected device can be found here:\n * https://docs.microsoft.com/en-us/azure/iot-hub/quickstart-control-device-node\n */\nconst { deviceId, methodName, payload, responseTimeoutInSeconds = 10, CONNECTION_STRING } = options.requiredProperties\n\nasync function main () {\n if (!deviceId || !methodName || !CONNECTION_STRING) {\n return send(new Error('REQUIRED: deviceId, methodName'))\n }\n\n const client = Client.fromConnectionString(CONNECTION_STRING)\n\n const result = await client.invokeDeviceMethod(deviceId, { methodName, payload, responseTimeoutInSeconds })\n send(null, result)\n}\n\nmain().catch(err => {\n console.log(err)\n send(new Error('Failed to invoke method \\'' + methodName + '\\': ' + err.message))\n})",
"metadata": {
"author": "",
"category": "",
"description": "<h4>AzureInvokeMethodOnDevice Actuator</h4>\n<br>\nInvoke a function on an Azure connected device.\n<br><br>\n<b>Properties</b>\n<ul>\n <li>\n methodName: The name of the function on the device which you would like to invoke\n </li>\n <li>\n responseTimeoutInSeconds (optional): Max time to wait for a response. (in seconds) (default: 10)\n </li>\n <li>\n deviceId: the device name registered on Azure\n </li>\n <li>\n payload: The value to provide to the invoked function\n </li>\n <li>\n CONNECTION_STRING: A valid Azure connection string\n </li>\n</ul>\n\nNOTE: Azure has three kinds of connection strings. You can read about the 'IoT Hub Connection String' property: use <a href=\"https://devblogs.microsoft.com/iotdev/understand-different-connection-strings-in-azure-iot-hub/\" target=\"_blank\">here</a>",
"documentationURL": "https://docs.microsoft.com/en-us/rest/api/iothub/service/invokedevicemethod",
"iconURL": "https://static.waylay.io/icons/azure.png",
"supportedStates": [],
"requiredProperties": [
"methodName",
"responseTimeoutInSeconds",
"deviceId",
"payload",
"CONNECTION_STRING"
],
"requiredRawData": []
},
"dependencies": {
"azure-iothub": "1.13.0"
}
}