Skip to content

Instantly share code, notes, and snippets.

@piccaso
Last active June 21, 2016 13:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save piccaso/da794433d3ef6335d79af75d0b7dcb26 to your computer and use it in GitHub Desktop.
Opentrigger Slack Example
[{
"id": "5e6a2292.b746fc",
"type": "mqtt-broker",
"z": "",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"verifyservercert": true,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"willTopic": "",
"willQos": "0",
"willRetain": null,
"willPayload": "",
"birthTopic": "",
"birthQos": "0",
"birthRetain": null,
"birthPayload": ""
}, {
"id": "6fe31be1.96c5d4",
"type": "function",
"z": "48a43edf.9b97e",
"name": "Coffee is ready!",
"func": "msg.payload = {\n \"attachments\": [\n {\n \"color\": \"#E22B1B\",\n \"pretext\": \":coffee: is ready!\",\n \"image_url\": \"https://i.imgur.com/yTtxUpj.gif\",\n //\"mrkdwn_in\": [\"text\",\"pretext\"],\n },\n ],\n};\n//msg.payload.username = \"opentrigger\";\n//msg.payload.channel = \"@flo\";\nmsg.headers = {'Content-Type':'application/json'};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 1000,
"y": 180,
"wires": [
["e65a21ec.4ff52"]
]
}, {
"id": "e65a21ec.4ff52",
"type": "http request",
"z": "48a43edf.9b97e",
"name": "slack",
"method": "POST",
"ret": "txt",
"url": "https://hooks.slack.com/services/CHANGE-ME",
"x": 1170,
"y": 180,
"wires": [
[]
]
}, {
"id": "e2f334c7.c261b8",
"type": "mqtt in",
"z": "48a43edf.9b97e",
"name": "Opentrigger Release",
"topic": "/opentrigger/signals/release",
"broker": "5e6a2292.b746fc",
"x": 180,
"y": 200,
"wires": [
["d7e84bc2.10da08"]
]
}, {
"id": "d7e84bc2.10da08",
"type": "json",
"z": "48a43edf.9b97e",
"name": "",
"x": 370,
"y": 200,
"wires": [
["4c91d8af.c56cf8"]
]
}, {
"id": "4c91d8af.c56cf8",
"type": "switch",
"z": "48a43edf.9b97e",
"name": "Age > 2sec",
"property": "payload.Age",
"propertyType": "msg",
"rules": [{
"t": "lt",
"v": "2000",
"vt": "num"
}, {
"t": "gte",
"v": "2000",
"vt": "num"
}],
"checkall": "true",
"outputs": 2,
"x": 530,
"y": 200,
"wires": [
["af43b44e.3b5828"],
["c2015a4c.7a6d38"]
]
}, {
"id": "af43b44e.3b5828",
"type": "switch",
"z": "48a43edf.9b97e",
"name": "Short",
"property": "payload.Packet.ManufacturerSpecific.SensorData.DigitalInputs",
"propertyType": "msg",
"rules": [{
"t": "eq",
"v": "0,1,1,1,1,1",
"vt": "str"
}, {
"t": "eq",
"v": "1,0,1,1,1,1",
"vt": "str"
}, {
"t": "eq",
"v": "1,1,0,1,1,1",
"vt": "str"
}, {
"t": "eq",
"v": "1,1,1,0,1,1",
"vt": "str"
}, {
"t": "eq",
"v": "1,1,1,1,0,1",
"vt": "str"
}, {
"t": "eq",
"v": "1,1,1,1,1,0",
"vt": "str"
}],
"checkall": "true",
"outputs": 6,
"x": 710,
"y": 120,
"wires": [
["6fe31be1.96c5d4"],
[],
[],
[],
[],
[]
]
}, {
"id": "c2015a4c.7a6d38",
"type": "switch",
"z": "48a43edf.9b97e",
"name": "Long",
"property": "payload.Packet.ManufacturerSpecific.SensorData.DigitalInputs",
"propertyType": "msg",
"rules": [{
"t": "eq",
"v": "0,1,1,1,1,1",
"vt": "str"
}, {
"t": "eq",
"v": "1,0,1,1,1,1",
"vt": "str"
}, {
"t": "eq",
"v": "1,1,0,1,1,1",
"vt": "str"
}, {
"t": "eq",
"v": "1,1,1,0,1,1",
"vt": "str"
}, {
"t": "eq",
"v": "1,1,1,1,0,1",
"vt": "str"
}, {
"t": "eq",
"v": "1,1,1,1,1,0",
"vt": "str"
}],
"checkall": "true",
"outputs": 6,
"x": 710,
"y": 280,
"wires": [
[],
[],
[],
[],
[],
[]
]
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment