Verwendung von MQTT, um Ihr Smarthome zu informieren, dass ein Alarm ausgelöst wurde
Q: Ich habe Ihren Leitfaden zur Verwendung des INSTAR (HTTP)-Alarmservers gefunden. Wäre es nicht sinnvoller, diese Ereignisse über den MQTT-Dienst zu veröffentlichen, den jede Full-HD-Kamera bietet? Auf diese Weise könnte ich sicher sein, dass jedes Alarmereignis von meinem Smarthome-System registriert wird.
A: Alle Alarmereignisse, die vom INSTAR HTTP Alarmserver veröffentlicht werden sind jetzt auch über den MQTT-Service erhältlich! Das entsprechende MQTT-Topic ist:
alarm/triggered
Sie müssen lediglich ein Abonnement zum Status-Topic hinzufügen, und Sie erhalten Updates über Alarmereignisse sowie darüber, welcher Dienst den Alarm ausgelöst hat:
- Alarmbereich 1 ausgelöst:
1
- Alarmbereich 2 ausgelöst:
2
- Alarmbereich 3 ausgelöst:
3
- Alarmbereich 4 ausgelöst:
4
- Alarm-In / PIR ausgelöst:
5
- Audio Alarm ausgelöst:
6
- Bewegungserkennung & ausgelöst (Bereich 1):
7
- Bewegungserkennung & ausgelöst (Bereich 2):
8
- Bewegungserkennung & ausgelöst (Bereich 3):
9
- Bewegungserkennung & ausgelöst (Bereich 4):
10
Im folgenden Beispiel fügte ich die erforderliche Subskription zu einen Node-RED Flow hinzu und übersetzte die Nachricht 1-10 in etwas, das für Menschen besser lesbar ist:
Sie können nun mit dem Hinzufügen dieser Status Ausgabe zu Ihrem Node-RED Dashboard fortfahren und diese danach auch mit Aktionen verknüpfen, die Node-RED bei jeder Aktualisierung eines Alarmauslösers auslösen soll:
Unten finden Sie den vollständigen Node-RED Flow, den Sie in Node-RED importieren können:
[
{
"id": "c025b147.f6afb",
"type": "tab",
"label": "MQTT Alarmserver",
"disabled": false,
"info": ""
},
{
"id": "60225cef.8303a4",
"type": "mqtt in",
"z": "c025b147.f6afb",
"name": "Alarm Server",
"topic": "instar/local/status/alarm/triggered",
"qos": "1",
"datatype": "auto",
"broker": "996228fe.ababc8",
"x": 83,
"y": 205,
"wires": [
[
"b72cdc96.64a87"
]
]
},
{
"id": "32ffd490.b0795c",
"type": "debug",
"z": "c025b147.f6afb",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 836,
"y": 198,
"wires": []
},
{
"id": "b72cdc96.64a87",
"type": "json",
"z": "c025b147.f6afb",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 223,
"y": 205,
"wires": [
[
"2ee4a407.5dc48c"
]
]
},
{
"id": "2ee4a407.5dc48c",
"type": "switch",
"z": "c025b147.f6afb",
"name": "",
"property": "payload.val",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "1",
"vt": "str"
},
{
"t": "eq",
"v": "2",
"vt": "str"
},
{
"t": "eq",
"v": "3",
"vt": "str"
},
{
"t": "eq",
"v": "4",
"vt": "str"
},
{
"t": "eq",
"v": "5",
"vt": "str"
},
{
"t": "eq",
"v": "6",
"vt": "str"
},
{
"t": "eq",
"v": "7",
"vt": "str"
},
{
"t": "eq",
"v": "8",
"vt": "str"
},
{
"t": "eq",
"v": "9",
"vt": "str"
},
{
"t": "eq",
"v": "10",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 10,
"x": 340,
"y": 205,
"wires": [
[
"defcbb16.bf38e8"
],
[
"6367a46f.f8964c"
],
[
"454780a4.b0ea7"
],
[
"75d792a8.79733c"
],
[
"a66275f7.6bc628"
],
[
"5dd27deb.981994"
],
[
"b543ec9e.31eea"
],
[
"5e6af36e.97c1fc"
],
[
"f4cab162.47c35"
],
[
"b9483cac.c0731"
]
]
},
{
"id": "defcbb16.bf38e8",
"type": "change",
"z": "c025b147.f6afb",
"name": "Area 1",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Area1",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 510,
"y": 40,
"wires": [
[
"32ffd490.b0795c",
"3275c8f4.1a4a58"
]
]
},
{
"id": "6367a46f.f8964c",
"type": "change",
"z": "c025b147.f6afb",
"name": "Area 2",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Area2",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 510,
"y": 79,
"wires": [
[
"32ffd490.b0795c",
"3275c8f4.1a4a58"
]
]
},
{
"id": "454780a4.b0ea7",
"type": "change",
"z": "c025b147.f6afb",
"name": "Area 3",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Area3",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 510,
"y": 119,
"wires": [
[
"32ffd490.b0795c",
"3275c8f4.1a4a58"
]
]
},
{
"id": "75d792a8.79733c",
"type": "change",
"z": "c025b147.f6afb",
"name": "Area 4",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Area4",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 510,
"y": 159,
"wires": [
[
"32ffd490.b0795c",
"3275c8f4.1a4a58"
]
]
},
{
"id": "a66275f7.6bc628",
"type": "change",
"z": "c025b147.f6afb",
"name": "AlarmIN / PIR",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "PIR",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 540,
"y": 199,
"wires": [
[
"32ffd490.b0795c",
"3275c8f4.1a4a58"
]
]
},
{
"id": "5dd27deb.981994",
"type": "change",
"z": "c025b147.f6afb",
"name": "Audioalarm",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Audioalarm",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 530,
"y": 239,
"wires": [
[
"32ffd490.b0795c",
"3275c8f4.1a4a58"
]
]
},
{
"id": "b543ec9e.31eea",
"type": "change",
"z": "c025b147.f6afb",
"name": "Area 1 + PIR",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Area1+PIR",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 530,
"y": 279,
"wires": [
[
"32ffd490.b0795c",
"3275c8f4.1a4a58"
]
]
},
{
"id": "5e6af36e.97c1fc",
"type": "change",
"z": "c025b147.f6afb",
"name": "Area 2 + PIR",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Area2+PIR",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 530,
"y": 319,
"wires": [
[
"32ffd490.b0795c",
"3275c8f4.1a4a58"
]
]
},
{
"id": "f4cab162.47c35",
"type": "change",
"z": "c025b147.f6afb",
"name": "Area 3 + PIR",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Area3+PIR",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 530,
"y": 359,
"wires": [
[
"32ffd490.b0795c",
"3275c8f4.1a4a58"
]
]
},
{
"id": "b9483cac.c0731",
"type": "change",
"z": "c025b147.f6afb",
"name": "Area 4 + PIR",
"rules": [
{
"t": "set",
"p": "payload",
"pt": "msg",
"to": "Area4+PIR",
"tot": "str"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 530,
"y": 399,
"wires": [
[
"32ffd490.b0795c",
"3275c8f4.1a4a58"
]
]
},
{
"id": "3275c8f4.1a4a58",
"type": "ui_text",
"z": "c025b147.f6afb",
"group": "9f1b0276.4860a",
"order": 0,
"width": 0,
"height": 0,
"name": "Alarm Trigger",
"label": "Alarm Trigger",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 837,
"y": 163,
"wires": []
},
{
"id": "996228fe.ababc8",
"type": "mqtt-broker",
"z": "",
"name": "INSTAR MQTT",
"broker": "192.168.2.117",
"port": "1883",
"clientid": "iored",
"usetls": false,
"compatmode": false,
"keepalive": "60",
"cleansession": true,
"birthTopic": "",
"birthQos": "0",
"birthPayload": "",
"closeTopic": "",
"closeQos": "0",
"closePayload": "",
"willTopic": "",
"willQos": "0",
"willPayload": ""
},
{
"id": "9f1b0276.4860a",
"type": "ui_group",
"z": "",
"name": "Alarmserver",
"tab": "c0706380.d93a",
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "c0706380.d93a",
"type": "ui_tab",
"z": "",
"name": "MQTT",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]