Skip to content

Commit 7ca46c5

Browse files
feat: add commands to update actuator digital twin on azure plaftorm
1 parent 64d7389 commit 7ca46c5

File tree

1 file changed

+118
-90
lines changed

1 file changed

+118
-90
lines changed

data/flows.json

Lines changed: 118 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@
114114
"y": 500,
115115
"wires": [
116116
[
117-
"c45a10208faeea88",
118-
"3b4b32fc0ebfe72e"
117+
"c45a10208faeea88"
119118
]
120119
]
121120
},
@@ -143,7 +142,7 @@
143142
"type": "function",
144143
"z": "09012e75c72a4968",
145144
"name": "UpdateActuatorState",
146-
"func": "",
145+
"func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/intensity_percentage\",\n \"value\": msg.intensity_percentage\n },\n {\n \"op\": \"add\",\n \"path\": \"/power_state\",\n \"value\": msg.state\n },\n {\n \"op\": \"add\",\n \"path\": \"/type\",\n \"value\": jsonData[msg.actuator_id][\"type\"]\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.actuator_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n",
147146
"outputs": 1,
148147
"noerr": 0,
149148
"initialize": "",
@@ -153,7 +152,8 @@
153152
"y": 740,
154153
"wires": [
155154
[
156-
"c45a10208faeea88"
155+
"c45a10208faeea88",
156+
"b19dbb8d1bfea2fc"
157157
]
158158
]
159159
},
@@ -464,28 +464,6 @@
464464
]
465465
]
466466
},
467-
{
468-
"id": "6a5968a77bdcb8ec",
469-
"type": "https-node",
470-
"z": "09012e75c72a4968",
471-
"name": "",
472-
"method": "use",
473-
"ret": "txt",
474-
"paytoqs": "ignore",
475-
"url": "",
476-
"tls": "",
477-
"persist": true,
478-
"proxy": "",
479-
"authType": "",
480-
"senderr": false,
481-
"x": 2050,
482-
"y": 720,
483-
"wires": [
484-
[
485-
"3e879afc64077b51"
486-
]
487-
]
488-
},
489467
{
490468
"id": "3a01a886905e5fed",
491469
"type": "http in",
@@ -697,28 +675,6 @@
697675
]
698676
]
699677
},
700-
{
701-
"id": "dd96318fc1b5b6c4",
702-
"type": "https-node",
703-
"z": "09012e75c72a4968",
704-
"name": "getToken",
705-
"method": "GET",
706-
"ret": "obj",
707-
"paytoqs": "body",
708-
"url": "",
709-
"tls": "",
710-
"persist": true,
711-
"proxy": "",
712-
"authType": "",
713-
"senderr": false,
714-
"x": 1620,
715-
"y": 180,
716-
"wires": [
717-
[
718-
"1453612b8d0a384b"
719-
]
720-
]
721-
},
722678
{
723679
"id": "1453612b8d0a384b",
724680
"type": "function",
@@ -1116,7 +1072,7 @@
11161072
"type": "file in",
11171073
"z": "09012e75c72a4968",
11181074
"name": "read file",
1119-
"filename": "/data/configFiles/type0.json",
1075+
"filename": "/data/configFiles/actuator_room_mapping.json",
11201076
"filenameType": "str",
11211077
"format": "utf8",
11221078
"chunk": false,
@@ -1231,20 +1187,6 @@
12311187
]
12321188
]
12331189
},
1234-
{
1235-
"id": "6b1290a059fc78a2",
1236-
"type": "serial in",
1237-
"z": "09012e75c72a4968",
1238-
"name": "",
1239-
"serial": "94b8abb47e4cb1f2",
1240-
"x": 110,
1241-
"y": 180,
1242-
"wires": [
1243-
[
1244-
"ead8458e27835fd5"
1245-
]
1246-
]
1247-
},
12481190
{
12491191
"id": "ead8458e27835fd5",
12501192
"type": "function",
@@ -1264,16 +1206,6 @@
12641206
]
12651207
]
12661208
},
1267-
{
1268-
"id": "ea1d80c07843fb89",
1269-
"type": "serial out",
1270-
"z": "09012e75c72a4968",
1271-
"name": "",
1272-
"serial": "94b8abb47e4cb1f2",
1273-
"x": 2070,
1274-
"y": 1280,
1275-
"wires": []
1276-
},
12771209
{
12781210
"id": "6c9f6e80226a5597",
12791211
"type": "inject",
@@ -1303,23 +1235,6 @@
13031235
]
13041236
]
13051237
},
1306-
{
1307-
"id": "3b4b32fc0ebfe72e",
1308-
"type": "debug",
1309-
"z": "09012e75c72a4968",
1310-
"name": "debug 1",
1311-
"active": true,
1312-
"tosidebar": true,
1313-
"console": false,
1314-
"tostatus": false,
1315-
"complete": "true",
1316-
"targetType": "full",
1317-
"statusVal": "",
1318-
"statusType": "auto",
1319-
"x": 1660,
1320-
"y": 440,
1321-
"wires": []
1322-
},
13231238
{
13241239
"id": "781486d011dadee8",
13251240
"type": "inject",
@@ -1406,5 +1321,118 @@
14061321
"ead8458e27835fd5"
14071322
]
14081323
]
1324+
},
1325+
{
1326+
"id": "6b1290a059fc78a2",
1327+
"type": "serial in",
1328+
"z": "09012e75c72a4968",
1329+
"name": "",
1330+
"serial": "94b8abb47e4cb1f2",
1331+
"x": 130,
1332+
"y": 180,
1333+
"wires": [
1334+
[
1335+
"ead8458e27835fd5"
1336+
]
1337+
]
1338+
},
1339+
{
1340+
"id": "ea1d80c07843fb89",
1341+
"type": "serial out",
1342+
"z": "09012e75c72a4968",
1343+
"name": "",
1344+
"serial": "94b8abb47e4cb1f2",
1345+
"x": 2090,
1346+
"y": 1280,
1347+
"wires": []
1348+
},
1349+
{
1350+
"id": "6a5968a77bdcb8ec",
1351+
"type": "https-node",
1352+
"z": "09012e75c72a4968",
1353+
"name": "",
1354+
"method": "use",
1355+
"ret": "txt",
1356+
"paytoqs": "ignore",
1357+
"url": "",
1358+
"tls": "",
1359+
"persist": true,
1360+
"proxy": "",
1361+
"authType": "",
1362+
"senderr": false,
1363+
"x": 2050,
1364+
"y": 720,
1365+
"wires": [
1366+
[
1367+
"3e879afc64077b51"
1368+
]
1369+
]
1370+
},
1371+
{
1372+
"id": "dd96318fc1b5b6c4",
1373+
"type": "https-node",
1374+
"z": "09012e75c72a4968",
1375+
"name": "getToken",
1376+
"method": "GET",
1377+
"ret": "obj",
1378+
"paytoqs": "body",
1379+
"url": "",
1380+
"tls": "",
1381+
"persist": true,
1382+
"proxy": "",
1383+
"authType": "",
1384+
"senderr": false,
1385+
"x": 1620,
1386+
"y": 180,
1387+
"wires": [
1388+
[
1389+
"1453612b8d0a384b"
1390+
]
1391+
]
1392+
},
1393+
{
1394+
"id": "105b0c2203081bf6",
1395+
"type": "inject",
1396+
"z": "09012e75c72a4968",
1397+
"name": "type4",
1398+
"props": [
1399+
{
1400+
"p": "payload"
1401+
},
1402+
{
1403+
"p": "topic",
1404+
"vt": "str"
1405+
}
1406+
],
1407+
"repeat": "",
1408+
"crontab": "",
1409+
"once": false,
1410+
"onceDelay": 0.1,
1411+
"topic": "",
1412+
"payload": "{\"type\": 4, \"actuator_id\": \"act1\", \"state\" : \"on\", \"intensity_percentage\": 40}",
1413+
"payloadType": "str",
1414+
"x": 110,
1415+
"y": 420,
1416+
"wires": [
1417+
[
1418+
"ead8458e27835fd5"
1419+
]
1420+
]
1421+
},
1422+
{
1423+
"id": "b19dbb8d1bfea2fc",
1424+
"type": "debug",
1425+
"z": "09012e75c72a4968",
1426+
"name": "debug 1",
1427+
"active": true,
1428+
"tosidebar": true,
1429+
"console": false,
1430+
"tostatus": false,
1431+
"complete": "false",
1432+
"statusVal": "",
1433+
"statusType": "auto",
1434+
"x": 1900,
1435+
"y": 860,
1436+
"wires": []
14091437
}
14101438
]

0 commit comments

Comments
 (0)