Tweet Enter or Leave your Waypoints

This flow send a tweet if you leave or enter any self defined waypoints. You can use for this the App "owntracks" on your Smartphone.

If you leave or Enter your Office will send a Tweet with Timestamp and your Waypoint. It will not Tweet your GEO-Location.

This flow needs some MQTT Broker.

mosquitto_pub -h localhost -t owntracks/username/device/event {"_type":"transition","lat":49.1383109,"lon":13.4277182,"acc":26,"tst":1444818585, "wtst":1444755752,"desc":"Home","event":"enter","tid":"21"}

mosquitto_pub -h localhost -t owntracks/username/device/event {"_type":"transition","lat":49.1383109,"lon":13.4277182,"acc":481,"tst":1444818772, "wtst":1444755752,"desc":"Home","event":"leave","tid":"21"}

Have Fun ...

More Information on Website http://blog.unxiweb.de

Best regards Joachim Hummel

[
    {
        "id": "a7c99df.f58366",
        "type": "mqtt-broker",
        "broker": "localhost",
        "port": "1883",
        "clientid": ""
    },
    {
        "id": "ba53f828.0f31f8",
        "type": "mqtt in",
        "name": "owntracks geofence",
        "topic": "owntracks/username/device/event",
        "broker": "a7c99df.f58366",
        "x": 198.0833282470703,
        "y": 318,
        "z": "c4d3f11a.54b14",
        "wires": [
            [
                "afaadfd0.39207",
                "c8d1c683.155af"
            ]
        ]
    },
    {
        "id": "afaadfd0.39207",
        "type": "debug",
        "name": "",
        "active": true,
        "complete": false,
        "x": 628.0833129882812,
        "y": 302.00000762939453,
        "z": "c4d3f11a.54b14",
        "wires": []
    },
    {
        "id": "c8d1c683.155af",
        "type": "function",
        "name": "Enter or Leave Location",
        "func": "// The received message is stored in 'msg'\n// It will have at least a 'payload' property:\n//   console.log(msg.payload);\n// The 'context' object is available to store state\n// between invocations of the function\n//   context = {};\nvar now = Date();\nvar message = \"\";\ndata = JSON.parse(msg.payload);\n\nif ( (data._type == \"transition\") && (data.event != undefined ) ) {\n\t\n\t\tif ( data.event == \"enter\" ) {\t\t\t\n\t\t\tmessage = \"Entering Location: \" + now;\n\t\t} else {\n\t\t\tmessage = \"Leaving Location: \" + now;\n\t\t}\n\t\t\n\t\tif ( data.desc != undefined ) {\n\t\t\t// Shared waypoint, comes with a description:\n\t\t\t\tmessage += data.desc;\n \t\t} else {\n \t\t\t// No description is set, non shared \"private\" waypoint\n \t\t\t\tmessage += data.lat + \",\" + data.lon;\n \t\t}\n }\n\nmsg.payload = message;\n//console.log(msg.payload);\n\nreturn msg;",
        "outputs": 1,
        "x": 469.08331298828125,
        "y": 427.00000762939453,
        "z": "c4d3f11a.54b14",
        "wires": [
            [
                "5b409eab.2d7f58",
                "9b8214f7.ea60a8",
                "1841ca10.f1853e"
            ]
        ]
    },
    {
        "id": "c9f14cc9.7e5948",
        "type": "mqtt in",
        "name": "WayPoints Home Smartphone",
        "topic": "owntracks/username/device/event",
        "broker": "a7c99df.f58366",
        "x": 185.0833282470703,
        "y": 239.08334350585938,
        "z": "c4d3f11a.54b14",
        "wires": [
            [
                "afaadfd0.39207",
                "c8d1c683.155af"
            ]
        ]
    },
    {
        "id": "5b409eab.2d7f58",
        "type": "switch",
        "name": "",
        "property": "payload",
        "rules": [
            {
                "t": "cont",
                "v": "Location"
            }
        ],
        "checkall": "true",
        "outputs": 1,
        "x": 682.0833129882812,
        "y": 418,
        "z": "c4d3f11a.54b14",
        "wires": [
            [
                "ad1826ec.4ef25"
            ]
        ]
    },
    {
        "id": "9b8214f7.ea60a8",
        "type": "debug",
        "name": "",
        "active": true,
        "complete": false,
        "x": 629.0833129882812,
        "y": 355.00000762939453,
        "z": "c4d3f11a.54b14",
        "wires": []
    },
    {
        "id": "d450952c.a3ab4",
        "type": "inject",
        "name": "Test Shared Waypoint",
        "topic": "",
        "payload": "{\"_type\": \"transition\", \"lat\": \"xxxx\", \"lon\": \"yyyy\", \"tst\": \"1391715492\", \"acc\": \"500.0\", \"batt\": \"48\", \"desc\": \"Shared Test Waypoint\", \"event\": \"enter\"}",
        "payloadType": "string",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 201.0833282470703,
        "y": 419,
        "z": "c4d3f11a.54b14",
        "wires": [
            [
                "c8d1c683.155af"
            ]
        ]
    },
    {
        "id": "d5310e2b.ee023",
        "type": "inject",
        "name": "Test Private Waypoint",
        "topic": "",
        "payload": "{\"_type\": \"transition\", \"lat\": \"xxxx\", \"lon\": \"yyyy\", \"tst\": \"1391715492\", \"acc\": \"500.0\", \"batt\": \"48\", \"event\": \"enter\"}",
        "payloadType": "string",
        "repeat": "",
        "crontab": "",
        "once": false,
        "x": 204.0833282470703,
        "y": 487.0000305175781,
        "z": "c4d3f11a.54b14",
        "wires": [
            [
                "c8d1c683.155af"
            ]
        ]
    },
    {
        "id": "1841ca10.f1853e",
        "type": "twitter out",
        "twitter": "",
        "name": "Tweet",
        "x": 640.0833129882812,
        "y": 503.0833435058594,
        "z": "c4d3f11a.54b14",
        "wires": []
    },
    {
        "id": "ad1826ec.4ef25",
        "type": "debug",
        "name": "",
        "active": true,
        "console": "false",
        "complete": "false",
        "x": 866.0833129882812,
        "y": 416.08331298828125,
        "z": "c4d3f11a.54b14",
        "wires": []
    }
]
unixweb

Flow Info

created 2 years ago

Node Types

Core
  • debug (x3)
  • function (x1)
  • inject (x2)
  • mqtt in (x2)
  • mqtt-broker (x1)
  • switch (x1)
  • twitter out (x1)

Tags

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