Skip to content

Commit 64d7389

Browse files
feat: add commands to update room digital twin on azure plaftorm
1 parent 642d635 commit 64d7389

File tree

1 file changed

+143
-9
lines changed

1 file changed

+143
-9
lines changed

data/flows.json

Lines changed: 143 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"type": "function",
105105
"z": "09012e75c72a4968",
106106
"name": "UpdateTemperature",
107-
"func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": jsonData[\"temperature\"][\"path\"],\n \"value\": parseInt(msg.temperature_value)\n }\n]\n\nmsg.payload = {}\n\nmsg.url = \"https://room.api.wcus.digitaltwins.azure.net/digitaltwins/\"+ msg.room_id +\"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n\n",
107+
"func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/temperature\",\n \"value\": parseFloat(msg.temperature_value)\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\"+ msg.room_id +\"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n\n",
108108
"outputs": 1,
109109
"noerr": 0,
110110
"initialize": "",
@@ -114,7 +114,8 @@
114114
"y": 500,
115115
"wires": [
116116
[
117-
"c45a10208faeea88"
117+
"c45a10208faeea88",
118+
"3b4b32fc0ebfe72e"
118119
]
119120
]
120121
},
@@ -123,7 +124,7 @@
123124
"type": "function",
124125
"z": "09012e75c72a4968",
125126
"name": "processSerialData",
126-
"func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.temperature_value = msg.serialData[\"temperature_value\"]\nmsg.temperature_unit = msg.serialData[\"temperature_unit\"]\n\nreturn msg;",
127+
"func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.temperature_value = msg.serialData[\"temperature_value\"]\n//msg.temperature_unit = msg.serialData[\"temperature_unit\"]\n\nreturn msg;",
127128
"outputs": 1,
128129
"noerr": 0,
129130
"initialize": "",
@@ -886,7 +887,7 @@
886887
"type": "function",
887888
"z": "09012e75c72a4968",
888889
"name": "processSerialData",
889-
"func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.luminosity_value = msg.serialData[\"luminosity_value\"]\nmsg.luminosity_unit = msg.serialData[\"luminosity_unit\"]\n\nreturn msg;",
890+
"func": "msg.room_id = msg.serialData[\"room_id\"]\nmsg.luminosity_value = msg.serialData[\"luminosity_value\"]\n//msg.luminosity_unit = msg.serialData[\"luminosity_unit\"]\n\nreturn msg;",
890891
"outputs": 1,
891892
"noerr": 0,
892893
"initialize": "",
@@ -924,7 +925,7 @@
924925
"type": "function",
925926
"z": "09012e75c72a4968",
926927
"name": "UpdateHumidity",
927-
"func": "\n\n",
928+
"func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/humidity\",\n \"value\": parseFloat(msg.humidity_percentage)\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.room_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n\n",
928929
"outputs": 1,
929930
"noerr": 0,
930931
"initialize": "",
@@ -943,7 +944,7 @@
943944
"type": "function",
944945
"z": "09012e75c72a4968",
945946
"name": "UpdateLuminosity",
946-
"func": "\n\n",
947+
"func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/luminosity\",\n \"value\": parseFloat(msg.luminosity_value)\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.room_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n",
947948
"outputs": 1,
948949
"noerr": 0,
949950
"initialize": "",
@@ -962,7 +963,7 @@
962963
"type": "function",
963964
"z": "09012e75c72a4968",
964965
"name": "UpdatePersonInside",
965-
"func": "",
966+
"func": "let jsonData = JSON.parse(msg.payload);\n\nmsg.payload = [\n {\n \"op\": \"add\",\n \"path\": \"/presence_inside\",\n \"value\": msg.person_inside\n }\n]\n\nmsg.url = \"https://digital-twin-layer.api.neu.digitaltwins.azure.net/digitaltwins/\" + msg.room_id + \"?api-version=2020-10-31\"\nmsg.method = \"patch\"\n\nreturn msg; \n",
966967
"outputs": 1,
967968
"noerr": 0,
968969
"initialize": "",
@@ -1255,8 +1256,8 @@
12551256
"initialize": "",
12561257
"finalize": "",
12571258
"libs": [],
1258-
"x": 280,
1259-
"y": 180,
1259+
"x": 320,
1260+
"y": 240,
12601261
"wires": [
12611262
[
12621263
"272e66b82d47e0e4"
@@ -1272,5 +1273,138 @@
12721273
"x": 2070,
12731274
"y": 1280,
12741275
"wires": []
1276+
},
1277+
{
1278+
"id": "6c9f6e80226a5597",
1279+
"type": "inject",
1280+
"z": "09012e75c72a4968",
1281+
"name": "type0",
1282+
"props": [
1283+
{
1284+
"p": "payload"
1285+
},
1286+
{
1287+
"p": "topic",
1288+
"vt": "str"
1289+
}
1290+
],
1291+
"repeat": "",
1292+
"crontab": "",
1293+
"once": false,
1294+
"onceDelay": 0.1,
1295+
"topic": "",
1296+
"payload": "{\"type\": 0, \"room_id\": \"room1\", \"temperature_value\": 24, \"temperature_unit\": \"celsius\"}",
1297+
"payloadType": "str",
1298+
"x": 110,
1299+
"y": 260,
1300+
"wires": [
1301+
[
1302+
"ead8458e27835fd5"
1303+
]
1304+
]
1305+
},
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+
},
1323+
{
1324+
"id": "781486d011dadee8",
1325+
"type": "inject",
1326+
"z": "09012e75c72a4968",
1327+
"name": "type1",
1328+
"props": [
1329+
{
1330+
"p": "payload"
1331+
},
1332+
{
1333+
"p": "topic",
1334+
"vt": "str"
1335+
}
1336+
],
1337+
"repeat": "",
1338+
"crontab": "",
1339+
"once": false,
1340+
"onceDelay": 0.1,
1341+
"topic": "",
1342+
"payload": "{\"type\": 1, \"room_id\": \"room1\", \"humidity_percentage\": 40}",
1343+
"payloadType": "str",
1344+
"x": 110,
1345+
"y": 300,
1346+
"wires": [
1347+
[
1348+
"ead8458e27835fd5"
1349+
]
1350+
]
1351+
},
1352+
{
1353+
"id": "8c25201c78c9ab3b",
1354+
"type": "inject",
1355+
"z": "09012e75c72a4968",
1356+
"name": "type2",
1357+
"props": [
1358+
{
1359+
"p": "payload"
1360+
},
1361+
{
1362+
"p": "topic",
1363+
"vt": "str"
1364+
}
1365+
],
1366+
"repeat": "",
1367+
"crontab": "",
1368+
"once": false,
1369+
"onceDelay": 0.1,
1370+
"topic": "",
1371+
"payload": "{\"type\": 2, \"room_id\": \"room1\", \"luminosity_value\": 1000}",
1372+
"payloadType": "str",
1373+
"x": 110,
1374+
"y": 340,
1375+
"wires": [
1376+
[
1377+
"ead8458e27835fd5"
1378+
]
1379+
]
1380+
},
1381+
{
1382+
"id": "26ec74664cb5ff41",
1383+
"type": "inject",
1384+
"z": "09012e75c72a4968",
1385+
"name": "type3",
1386+
"props": [
1387+
{
1388+
"p": "payload"
1389+
},
1390+
{
1391+
"p": "topic",
1392+
"vt": "str"
1393+
}
1394+
],
1395+
"repeat": "",
1396+
"crontab": "",
1397+
"once": false,
1398+
"onceDelay": 0.1,
1399+
"topic": "",
1400+
"payload": "{\"type\": 3, \"room_id\": \"room1\", \"person_inside\": true}",
1401+
"payloadType": "str",
1402+
"x": 110,
1403+
"y": 380,
1404+
"wires": [
1405+
[
1406+
"ead8458e27835fd5"
1407+
]
1408+
]
12751409
}
12761410
]

0 commit comments

Comments
 (0)