Skip to content

Instantly share code, notes, and snippets.

@MCeddy MCeddy/flow.json
Created Nov 28, 2019

Embed
What would you like to do?
node-red flow - presence detection
[
{
"id": "6a823385.834cbc",
"type": "tab",
"label": "AWTRIX",
"disabled": false,
"info": ""
},
{
"id": "91c2dade.0c6518",
"type": "mqtt out",
"z": "6a823385.834cbc",
"name": "AWTRIX API",
"topic": "awtrix/basics",
"qos": "",
"retain": "",
"broker": "caf9b2ea.7b2d8",
"x": 1510,
"y": 300,
"wires": []
},
{
"id": "e37da6d4.f06408",
"type": "mqtt in",
"z": "6a823385.834cbc",
"name": "OpenWrt - wifi clients",
"topic": "openwrt/client",
"qos": "2",
"datatype": "auto",
"broker": "caf9b2ea.7b2d8",
"x": 180,
"y": 220,
"wires": [["e83cdda.b50442"]]
},
{
"id": "c95aa2db.78694",
"type": "switch",
"z": "6a823385.834cbc",
"name": "is my smartphone",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "MAC Address of your smartphone",
"vt": "str"
},
{
"t": "eq",
"v": "MAC Address of your second smartphone ;)",
"vt": "str"
},
{
"t": "else"
}
],
"checkall": "false",
"repair": false,
"outputs": 3,
"x": 730,
"y": 120,
"wires": [["84def69c.861498"], ["84def69c.861498"], []],
"info": "check MAC address for identify my smartphone"
},
{
"id": "84def69c.861498",
"type": "change",
"z": "6a823385.834cbc",
"name": "save time",
"rules": [
{
"t": "set",
"p": "smartphoneLastSeen",
"pt": "flow",
"to": "",
"tot": "date"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 960,
"y": 120,
"wires": [["41a8ee07.6a652"]]
},
{
"id": "255b66b1.97827a",
"type": "inject",
"z": "6a823385.834cbc",
"name": "all 15 minutes",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "900",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 160,
"y": 380,
"wires": [["a4c7f8d9.837528"]]
},
{
"id": "db276929.44a6d8",
"type": "switch",
"z": "6a823385.834cbc",
"name": "Gerät länger als 5 Minuten nicht gesehen",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "gt",
"v": "300000",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 820,
"y": 380,
"wires": [["e2eb2e17.b185c"]],
"info": "Prüft, ob das Gerät innerhalt eines bestimmten Zeitraums (in ms) identifiziert wurde."
},
{
"id": "a4c7f8d9.837528",
"type": "function",
"z": "6a823385.834cbc",
"name": "calc diff",
"func": "var now = new Date().getTime();\nvar lastSeen = flow.get('smartphoneLastSeen');\nvar diff = now - lastSeen; // in ms\n\nmsg.payload = diff;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 420,
"y": 380,
"wires": [["db276929.44a6d8"]]
},
{
"id": "e83cdda.b50442",
"type": "time-range-switch",
"z": "6a823385.834cbc",
"name": "zwischen 7 und 22 Uhr",
"lat": "",
"lon": "",
"startTime": "07:00",
"endTime": "22:00",
"startOffset": 0,
"endOffset": 0,
"x": 460,
"y": 220,
"wires": [["c95aa2db.78694"], []]
},
{
"id": "eb403fcf.5a8ef",
"type": "inject",
"z": "6a823385.834cbc",
"name": "22 Uhr",
"topic": "",
"payload": "",
"payloadType": "str",
"repeat": "",
"crontab": "00 22 * * *",
"once": false,
"onceDelay": 0.1,
"x": 920,
"y": 500,
"wires": [["e2eb2e17.b185c"]]
},
{
"id": "e2eb2e17.b185c",
"type": "change",
"z": "6a823385.834cbc",
"name": "Bildschirm ausschalten",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"power\":false}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1200,
"y": 380,
"wires": [["91c2dade.0c6518"]]
},
{
"id": "41a8ee07.6a652",
"type": "change",
"z": "6a823385.834cbc",
"name": "Bildschirm einschalten",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "{\"power\":true}",
"tot": "json"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 1200,
"y": 240,
"wires": [["91c2dade.0c6518"]]
},
{
"id": "caf9b2ea.7b2d8",
"type": "mqtt-broker",
"z": "",
"name": "localhost",
"broker": "localhost",
"port": "1883",
"clientid": "",
"usetls": false,
"compatmode": true,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.