Opentrigger Slack Example

see: https://www.gitbook.com/book/acolono/opentrigger/ Opentrigger Slack

[{
    "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": "e55eb65d.362d78",
    "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": 960,
    "y": 160,
    "wires": [
        ["bcb68729.db8178"]
    ]
}, {
    "id": "bcb68729.db8178",
    "type": "http request",
    "z": "48a43edf.9b97e",
    "name": "slack",
    "method": "POST",
    "ret": "txt",
    "url": "https://hooks.slack.com/services/CHANGE-ME",
    "x": 1130,
    "y": 160,
    "wires": [
        []
    ]
}, {
    "id": "364f664.3a4729a",
    "type": "mqtt in",
    "z": "48a43edf.9b97e",
    "name": "Opentrigger Release",
    "topic": "/opentrigger/signals/release",
    "broker": "5e6a2292.b746fc",
    "x": 140,
    "y": 180,
    "wires": [
        ["a9888d3a.eaffa"]
    ]
}, {
    "id": "a9888d3a.eaffa",
    "type": "json",
    "z": "48a43edf.9b97e",
    "name": "",
    "x": 330,
    "y": 180,
    "wires": [
        ["c07b16f4.e44cd8"]
    ]
}, {
    "id": "c07b16f4.e44cd8",
    "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": 490,
    "y": 180,
    "wires": [
        ["3e5aeb23.b6e414"],
        ["8d9caef.8a7a55"]
    ]
}, {
    "id": "3e5aeb23.b6e414",
    "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": 670,
    "y": 100,
    "wires": [
        [],
        [],
        [],
        [],
        [],
        ["e55eb65d.362d78"]
    ]
}, {
    "id": "8d9caef.8a7a55",
    "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": 670,
    "y": 260,
    "wires": [
        [],
        [],
        [],
        [],
        [],
        []
    ]
}]
piccaso

Flow Info

created 10 months ago

Node Types

Core
  • function (x1)
  • http request (x1)
  • json (x1)
  • mqtt in (x1)
  • mqtt-broker (x1)
  • switch (x3)

Tags

  • Slack
  • Opentrigger
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option