@ifp-software/node-red-contrib-oee-ai-connector
Version:
Easily connect your production machines to oee.ai – The Industry 4.0 solution for OEE optimization.
237 lines (236 loc) • 6.38 kB
JSON
[
{
"id": "54da8a36a462aa7b",
"type": "tab",
"label": "Responding to loss-alert",
"disabled": false,
"info": "",
"env": []
},
{
"id": "ac29cae9f0cf645f",
"type": "mqtt in",
"z": "54da8a36a462aa7b",
"name": "Tablet Notification",
"topic": "oee/tablet/$TABLET_ID/+/loss-alert",
"qos": "2",
"datatype": "auto",
"broker": "248a8bfc78b28170",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 210,
"y": 320,
"wires": [
[
"76ef47f71aa08683"
]
]
},
{
"id": "f7f3b411e27b71df",
"type": "mqtt out",
"z": "54da8a36a462aa7b",
"name": "Send to tablet",
"topic": "oee/tablet/$TABLET_ID/alert-reason",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "248a8bfc78b28170",
"x": 1140,
"y": 280,
"wires": []
},
{
"id": "646f58fa7dbd4064",
"type": "function",
"z": "54da8a36a462aa7b",
"name": "set payload",
"func": "if(msg.comment != null){\n msg.payload = {\n \"data\": {\n \"id\": msg.payload.data.id,\n \"attributes\": {\n \"comment\": msg.comment\n },\n \"relationships\": {\n \"loss-reason\": {\n \"data\": {\n \"id\": msg.lossReasonID\n }\n }\n }\n }\n }\n}\nelse{\n msg.payload = {\n \"data\": {\n \"id\": msg.payload.data.id,\n \"relationships\": {\n \"loss-reason\": {\n \"data\": {\n \"id\": msg.lossReasonID\n }\n }\n }\n }\n }\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 950,
"y": 280,
"wires": [
[
"f7f3b411e27b71df"
]
]
},
{
"id": "3cb47bce960bb863",
"type": "switch",
"z": "54da8a36a462aa7b",
"name": "has loss-reason",
"property": "payload.data.relationships.loss-reason.data",
"propertyType": "msg",
"rules": [
{
"t": "null"
},
{
"t": "else"
}
],
"checkall": "true",
"repair": false,
"outputs": 2,
"x": 600,
"y": 320,
"wires": [
[
"6b289be7354d239f"
],
[
"c06667ddad16a5d8"
]
]
},
{
"id": "c06667ddad16a5d8",
"type": "debug",
"z": "54da8a36a462aa7b",
"name": "loss-alerts",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 790,
"y": 340,
"wires": []
},
{
"id": "6b289be7354d239f",
"type": "change",
"z": "54da8a36a462aa7b",
"name": "Attributes",
"rules": [
{
"t": "set",
"p": "lossReasonID",
"pt": "msg",
"to": "",
"tot": "str"
},
{
"t": "set",
"p": "comment",
"pt": "msg",
"to": "",
"tot": "str"
},
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "oee/tablet/$TABLET_ID/alert-reason",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 780,
"y": 280,
"wires": [
[
"646f58fa7dbd4064"
]
]
},
{
"id": "0d3b9e9911aed55b",
"type": "comment",
"z": "54da8a36a462aa7b",
"name": "^^ set loss-reason attributes",
"info": "",
"x": 840,
"y": 240,
"wires": []
},
{
"id": "83f551515bb8d56f",
"type": "comment",
"z": "54da8a36a462aa7b",
"name": "subscribe to topic",
"info": "In this Node you need to put your tablets ID.\nIf you just want Notifications of the tablets \nLocations and not the child locations, delete \nthe \"/+\" part.",
"x": 200,
"y": 280,
"wires": []
},
{
"id": "d1a98852a2de81c8",
"type": "comment",
"z": "54da8a36a462aa7b",
"name": "subscribe to topic",
"info": "",
"x": 1140,
"y": 240,
"wires": []
},
{
"id": "76ef47f71aa08683",
"type": "switch",
"z": "54da8a36a462aa7b",
"name": "is loss-alert",
"property": "payload.data.type",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "loss-alert",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 410,
"y": 320,
"wires": [
[
"3cb47bce960bb863"
]
]
},
{
"id": "248a8bfc78b28170",
"type": "mqtt-broker",
"name": "Ben Pauly Changeover Test",
"broker": "mqtt.oee.ai",
"port": "1883",
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": "4",
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willPayload": "",
"willMsg": {},
"sessionExpiry": ""
}
]