Skip to content

Instantly share code, notes, and snippets.

@ethanpierce
Last active August 6, 2019 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ethanpierce/0ca77d55d6e0859f6bc1c84b7c926c99 to your computer and use it in GitHub Desktop.
Save ethanpierce/0ca77d55d6e0859f6bc1c84b7c926c99 to your computer and use it in GitHub Desktop.
Rules Engine Signal Device
[
{
"id": "b69a84fc.80a2b8",
"type": "subflow",
"name": "Log Error (3)",
"info": "This sub flow will log an error to the ManageDevices FileMaker applicaiton on the solarsync.io FileMaker Server.",
"category": "Error Handling",
"in": [
{
"x": 60,
"y": 40,
"wires": [
{
"id": "917c47b5.69f9a8"
},
{
"id": "83351100.c6e2a"
}
]
}
],
"out": [
{
"x": 360,
"y": 40,
"wires": [
{
"id": "b69a84fc.80a2b8",
"port": 0
}
]
}
]
},
{
"id": "4dab9f24.ac3f48",
"type": "catch",
"z": "b69a84fc.80a2b8",
"name": "Catch Error Logging Issue",
"scope": [
"65c61488.62202c",
"9adeb8e3.5b0c68",
"56132c65.8cb284"
],
"x": 270,
"y": 140,
"wires": [
[
"917c47b5.69f9a8"
]
]
},
{
"id": "56132c65.8cb284",
"type": "dapi-create-record",
"z": "b69a84fc.80a2b8",
"name": "Create Error Log Entry",
"client": "",
"layout": "Log API",
"layoutType": "str",
"data": "error",
"dataType": "msg",
"scripts": "",
"scriptsType": "none",
"merge": "false",
"mergeType": "bool",
"output": "payload",
"x": 720,
"y": 40,
"wires": [
[]
]
},
{
"id": "9adeb8e3.5b0c68",
"type": "function",
"z": "b69a84fc.80a2b8",
"name": "Create Error Log",
"func": "msg.error = {\n error: msg.error,\n payload: msg.payload\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 500,
"y": 40,
"wires": [
[
"56132c65.8cb284"
]
]
},
{
"id": "917c47b5.69f9a8",
"type": "function",
"z": "b69a84fc.80a2b8",
"name": "Send Error Message",
"func": "msg.payload = msg.error.message\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 520,
"y": 100,
"wires": [
[
"8568b987.2612a"
]
]
},
{
"id": "8568b987.2612a",
"type": "debug",
"z": "b69a84fc.80a2b8",
"name": "Log Error",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"x": 769.5,
"y": 100,
"wires": []
},
{
"id": "83351100.c6e2a",
"type": "debug",
"z": "b69a84fc.80a2b8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 540,
"y": 280,
"wires": []
},
{
"id": "71fc59f1.b53a2",
"type": "tab",
"label": "Signal IOT Device",
"disabled": false,
"info": ""
},
{
"id": "453bb507.21d6e4",
"type": "http in",
"z": "71fc59f1.b53a2",
"name": "",
"url": "/:coreid/signal",
"method": "post",
"upload": false,
"swaggerDoc": "",
"x": 170,
"y": 180,
"wires": [
[
"1301f728.3f2551"
]
]
},
{
"id": "f704072f.715d",
"type": "change",
"z": "71fc59f1.b53a2",
"name": "Set Layout Context And Query",
"rules": [
{
"t": "set",
"p": "topic",
"pt": "msg",
"to": "devid",
"tot": "str"
},
{
"t": "set",
"p": "layout",
"pt": "flow",
"to": "Device API",
"tot": "str"
},
{
"t": "set",
"p": "coreid",
"pt": "msg",
"to": "req.params.coreid",
"tot": "msg"
},
{
"t": "set",
"p": "query",
"pt": "msg",
"to": "{}",
"tot": "json"
},
{
"t": "set",
"p": "query.coreid",
"pt": "msg",
"to": "coreid",
"tot": "msg"
},
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "coreid",
"tot": "msg"
},
{
"t": "set",
"p": "limit",
"pt": "msg",
"to": "1",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 650,
"y": 180,
"wires": [
[
"729923c8.e89d8c"
]
]
},
{
"id": "5a6cc493.c70b0c",
"type": "dapi-edit-record",
"z": "71fc59f1.b53a2",
"name": "",
"client": "",
"layout": "layout",
"layoutType": "flow",
"recordId": "device.recordId",
"recordIdType": "flow",
"data": "payload",
"dataType": "msg",
"scripts": "",
"scriptsType": "none",
"merge": "true",
"mergeType": "bool",
"output": "payload",
"x": 1870,
"y": 180,
"wires": [
[
"aff020bb.299db"
]
]
},
{
"id": "bf3a593c.8b6ff8",
"type": "switch",
"z": "71fc59f1.b53a2",
"name": "",
"property": "complete",
"propertyType": "flow",
"rules": [
{
"t": "true"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 1450,
"y": 180,
"wires": [
[
"8672080f.620ce"
]
]
},
{
"id": "8672080f.620ce",
"type": "change",
"z": "71fc59f1.b53a2",
"name": "",
"rules": [
{
"t": "delete",
"p": "payload.id",
"pt": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1650,
"y": 180,
"wires": [
[
"5a6cc493.c70b0c"
]
]
},
{
"id": "84b372ee.ad8938",
"type": "catch",
"z": "71fc59f1.b53a2",
"name": "",
"scope": null,
"x": 140,
"y": 240,
"wires": [
[
"a86ef833.2a6fb"
]
]
},
{
"id": "2514167d.d41422",
"type": "http response",
"z": "71fc59f1.b53a2",
"name": "",
"statusCode": "",
"headers": {},
"x": 2290,
"y": 180,
"wires": []
},
{
"id": "1301f728.3f2551",
"type": "change",
"z": "71fc59f1.b53a2",
"name": "",
"rules": [
{
"t": "set",
"p": "res",
"pt": "flow",
"to": "res",
"tot": "msg"
},
{
"t": "set",
"p": "req",
"pt": "flow",
"to": "req",
"tot": "msg"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 400,
"y": 180,
"wires": [
[
"f704072f.715d"
]
]
},
{
"id": "aff020bb.299db",
"type": "change",
"z": "71fc59f1.b53a2",
"name": "Populate Request",
"rules": [
{
"t": "set",
"p": "req",
"pt": "msg",
"to": "req",
"tot": "flow"
},
{
"t": "set",
"p": "res",
"pt": "msg",
"to": "res",
"tot": "flow"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 2090,
"y": 180,
"wires": [
[
"2514167d.d41422"
]
]
},
{
"id": "2954c232.f86a5e",
"type": "http response",
"z": "71fc59f1.b53a2",
"name": "",
"statusCode": "500",
"headers": {},
"x": 2620,
"y": 240,
"wires": []
},
{
"id": "44a49f21.83ba8",
"type": "particle-api",
"z": "71fc59f1.b53a2",
"name": "Signal Device",
"auth": "",
"method": "put",
"url": "",
"x": 1420,
"y": 100,
"wires": [
[
"bf3a593c.8b6ff8"
]
]
},
{
"id": "a86ef833.2a6fb",
"type": "subflow:b69a84fc.80a2b8",
"z": "71fc59f1.b53a2",
"name": "",
"x": 1340,
"y": 240,
"wires": [
[
"2954c232.f86a5e"
]
]
},
{
"id": "4a0259a2.653bd8",
"type": "debug",
"z": "71fc59f1.b53a2",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"x": 1410,
"y": 40,
"wires": []
},
{
"id": "729923c8.e89d8c",
"type": "trigger",
"z": "71fc59f1.b53a2",
"op1": "",
"op2": "{\"off\":true}",
"op1type": "pay",
"op2type": "json",
"duration": "10",
"extend": false,
"units": "s",
"reset": "",
"bytopic": "all",
"name": "",
"x": 1050,
"y": 180,
"wires": [
[
"36d9fbc4.d745c4",
"4a0259a2.653bd8"
]
]
},
{
"id": "36d9fbc4.d745c4",
"type": "function",
"z": "71fc59f1.b53a2",
"name": "Set Signal",
"func": "msg.method = \"PUT\"\n\nmsg.url = \"/v1/devices/\" + msg.coreid\n\nmsg.payload = {\n signal: msg.payload.off ? 0 : 1\n}\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 1230,
"y": 180,
"wires": [
[
"44a49f21.83ba8",
"4a0259a2.653bd8"
]
]
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment