Using MQTT to inform your Smarthome that an Alarm was Triggered
Q: I found your guide to use the INSTAR (HTTP) Alarmserver. Wouldn't it make more sense to publish those events through the MQTT service that every Full HD cameras offers? This way I would be able to be sure that every alarm event is registered by my smarthome system.
A: All alarm events that published by the INSTAR HTTP Alarmserver can now also be accessed through the MQTT Service! The corresponding MQTT Topic is:
alarm/triggered
All you need to do is adding a subscription to the Status Topic and you will receive updates about alarm events as well as what service triggered the alarm:
- 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
In the following example I added the necessary subscription to a Node-RED Flow and translated the payload 1-10 to something more human-readable:
You can now continue with adding this output to your Node-RED Dashboard and continue with adding actions that Node-RED should trigger whenever a alarm trigger update arrives:
You can find the complete Node-RED Flow below, so you can import it into Node-RED:
[
{
"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
}
]