Using the INSTAR MQTT Alarmserver to track Moving Objects

Q: Is it possible to use Node-RED to have my Full HD pan&tilt camera follow moving objects ?

Mike Polinowski
INSTAR MQTT
Firmware Update
Full HD Series
INSTAR Deutschland GmbH
INSTAR MQTT

Make your camera the heart of your smart home

INSTAR MQTT

Using the MQTT interface of your INSTAR Full HD cameras you can connect them to an existing smarthome system (Home Assistant, OpenHAB, Node-RED, Athom Homey, Homematic, ioBroker, Loxone, homee) can be added. Or even make it the main broker for your MQTT sensors. MQTT allows you to automate ALL functions of your camera and link them to other services in your smarthome.

Mike Polinowski
IFTTT Applets
Firmware Update
Full HD Series
INSTAR Cloud
INSTAR Deutschland GmbH
INSTAR IFTTT Applets

Control your camera via the IFTTT online service

INSTAR IFTTT

On the IFTTT platform, we provided a service called INSTAR. The INSTAR applets provide you with the ability to control some settings of your INSTAR camera or INSTAR Cloud with IFTTT. You can connect INSTAR with triggers for location (Geo Location) and date & time, send notifications and much more. For example, you can connect INSTAR applets to the IFTTT location service and automatically disable the alarm when you arrive home. You can also use the INSTAR applets to create your own automation and connect them to other third-party applets.

A: You can use INSTAR MQTT Alarmserver to notify Node-RED about detected movements. You can start by selecting two areas you want to use to trigger a pan or tilt movement of your camera:

INSTAR MQTT Alarmserver and Node-RED

We now want to tell Node-RED to move our camera to the left, when the left motion detection area (Area 1) is triggered, and to the right, in case of the right detection area (Area 4).

To make sure that our camera does not "get lost" following shadows or light reflections, we will first set preset position 1 in a sensible center position:

INSTAR MQTT Alarmserver and Node-RED

And tell our camera to return to this position (Park Position) after a reasonable amount of time:

INSTAR MQTT Alarmserver and Node-RED

Node-RED now needs a Subscription to the MQTT Status Topic status/alarm/triggered. As we have shown before, this topic receive an update with the value 1-4 if Area 1 to 4 are triggered.

When we receive a payload of {"val":"1"} we now know that the left area was triggered and we have to move to left. The same way a payload of {"val":"4"} means that we have to move one step to the right. The complete Node-RED Flow looks like this (see JSON export at the end of this article):

INSTAR MQTT Alarmserver and Node-RED

And here is the flow in action:

INSTAR MQTT Alarmserver and Node-RED

[
    {
        "id": "b3f2131d.c323e",
        "type": "mqtt in",
        "z": "c025b147.f6afb",
        "name": "Alarm Server",
        "topic": "instar/local/status/alarm/triggered",
        "qos": "1",
        "datatype": "auto",
        "broker": "996228fe.ababc8",
        "x": 90,
        "y": 620,
        "wires": [
            [
                "7e41db00.f5ed94"
            ]
        ]
    },
    {
        "id": "7e41db00.f5ed94",
        "type": "json",
        "z": "c025b147.f6afb",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 230,
        "y": 620,
        "wires": [
            [
                "da03fe2f.869de"
            ]
        ]
    },
    {
        "id": "da03fe2f.869de",
        "type": "switch",
        "z": "c025b147.f6afb",
        "name": "",
        "property": "payload.val",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "1",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "4",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 347,
        "y": 620,
        "wires": [
            [
                "682bc199.6b418"
            ],
            [
                "ec0056bc.645fa8"
            ]
        ]
    },
    {
        "id": "682bc199.6b418",
        "type": "change",
        "z": "c025b147.f6afb",
        "name": "Area 1 => Move Left",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"val\":\"left\"}",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 520,
        "y": 600,
        "wires": [
            [
                "5bbe46a4.047128"
            ]
        ]
    },
    {
        "id": "ec0056bc.645fa8",
        "type": "change",
        "z": "c025b147.f6afb",
        "name": "Area 4 => Move Right",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "{\"val\":\"right\"}",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 520,
        "y": 640,
        "wires": [
            [
                "5bbe46a4.047128"
            ]
        ]
    },
    {
        "id": "5bbe46a4.047128",
        "type": "mqtt out",
        "z": "c025b147.f6afb",
        "name": "features/ptz/movestep",
        "topic": "instar/local/features/ptz/movestep",
        "qos": "1",
        "retain": "false",
        "broker": "996228fe.ababc8",
        "x": 740,
        "y": 620,
        "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": ""
    }
]