ioBroker with your WQHD INSTAR MQTTv5 Broker

Q: I want to use my IN-9408 2k+ with the new Version 7 of ioBroker. The camera MQTT Broker supports the new MQTTv5. How can use this interface to control my camera?

A: Start by installing the MQTT-Client Adapter (you do not need the MQTT Broker/Client):

ioBroker with your WQHD INSTAR MQTTv5 Broker

Now configure your camera MQTT broker to operate in Broker Mode - so it becomes the primary MQTT broker in your network:

ioBroker with your WQHD INSTAR MQTTv5 Broker

Now we can configure the ioBroker MQTT Client Adapter with the IP address of the Broker camera, the Broker port and login. Don't forget to set the MQTT Version to 5. Optionally, you can define a topic the client should use to announce that it connected or is about to disconnect - e.g. iobroker/state with the values alive and dead:

ioBroker with your WQHD INSTAR MQTTv5 Broker

The client will try to connect when you save your settings. In the following screenshot I connected the MQTT Explorer to verify that the iobroker/state topic appears:

ioBroker with your WQHD INSTAR MQTTv5 Broker

Now I can go back to the ioBroker MQTT-Client configuration and add an additional subscription. All my cameras are configured to use the MQTT Prefix cameras followed by a Camera ID. To subscribe to all my camera topics I need a wildcard subscription for cameras/#:

ioBroker with your WQHD INSTAR MQTTv5 Broker

After saving the configuration I can now check the Object Tree and see if the camera topics start arriving. Note the topics you are seeing here are the retained Status Topics that reflect your current camera state - and not the Command Topics you need to change the state on your camera:

ioBroker with your WQHD INSTAR MQTTv5 Broker

We can now use ioBroker to take control of our camera. Every topic listed can be updated - either manually through the ioBroker interface or by an automation script. As an example I will use the Privacy Mask as an example:

ioBroker with your WQHD INSTAR MQTTv5 Broker

But as mentioned above we cannot update the Status Topic. We need the Command Topic to tell our camera to turn those masks on or off. Again I am going to use the MQTT Explorer - this time to send these commands to my camera and have them show up in the ioBroker Object Tree.

The camera I am using has the prefix cameras and camera ID 118 - the status and command topic for the privacy mask 1 is accordingly:

  • Status Topic: cameras/118/status/multimedia/privacy/region4/enable
  • Command Topic: cameras/118/multimedia/privacy/region4/enable
  • RAW Command Topic: cameras/118/multimedia/privacy/region4/enable/raw

NOTE: the RAW topic allows us to use string values for the command instead of the regular JSON expression - so it is only 0, 1 instead of {"val":"0"}, {"val":"1"}

ioBroker with your WQHD INSTAR MQTTv5 Broker

In addition I want to have a single variable that I can toggle that will then toggle all areas at once. I will use the topic cameras/privacy that will expect either an 0 or 1 to toggle all privacy masks at once:

ioBroker with your WQHD INSTAR MQTTv5 Broker

Make sure that ioBroker noticed the new topics:

ioBroker with your WQHD INSTAR MQTTv5 Broker

And make sure that ioBroker has both the subscription as well as the right to update the topic. This setting can be found under the cog wheel icon on the far right of the list entry:

ioBroker with your WQHD INSTAR MQTTv5 Broker

Here activate both the Subscription as well as the Publish option:

ioBroker with your WQHD INSTAR MQTTv5 Broker

Now jump over to the Skripte adapter - you might have to install it from the Adapter menu first. and select the if-then-else Rules:

ioBroker with your WQHD INSTAR MQTTv5 Broker

Here we now have to drag a State (Zustand) block into the if column on the left. Here click on the button with 3 dots and select the cameras/privacy toggle from the MQTT-Client objects:

ioBroker with your WQHD INSTAR MQTTv5 Broker

In the then block on the right we need to place 4 Set State (Zustand setzen) blocks and add the 4 RAW Command Topics for the 4 privacy masks:

  • cameras/118/multimedia/privacy/region1/enable/raw
  • cameras/118/multimedia/privacy/region2/enable/raw
  • cameras/118/multimedia/privacy/region3/enable/raw
  • cameras/118/multimedia/privacy/region4/enable/raw

Make sure the use trigger value option is checked. This will forward the 1 or 0 received by the cameras/privacy topic and automatically turn each mask on or off:

ioBroker with your WQHD INSTAR MQTTv5 Broker

The complete Script now looks like:

ioBroker with your WQHD INSTAR MQTTv5 Broker

I am now using the MQTT Explorer to update the cameras/privacy topic. Sending the value 1 triggers the script and the value is forwarded to each RAW Command Topic turning all privacy areas on at once:

ioBroker with your WQHD INSTAR MQTTv5 Broker

Now all you need to do is the use the cameras/privacy topic in an automation script you are already using or add it to your ioBroker Vis in form of a button.

And of course the privacy mask topic multimedia/privacy/region1/enable can be replaced with any of the many MQTT topics from the MQTTv5 API. Turning on the alarm, moving alarm areas or pan your Pan&Tilt camera to another position. All done through MQTT!