OpenGate provides an MQTT connector that lets devices exchange messages with the platform
using a single TCP connection: publish collected data, receive operation requests, send
operation responses and ask for pending operations. The following sections describe how to
connect, the default OpenGate topics, and how to handle data collection and operations
over MQTT.
This section shows how to use OpenGate MQTT connector for data collection.
Using MQTT, your devices only need one TCP connection to exchange messages with the platform: publish collected data, receive operation requests, send operation responses, ask for pending operations, etc.
How to connect to OpenGate MQTT connector
These are the parameters to establish a MQTT connection with OpenGate:
Host: api.opengate.es
Port: 1883
User: your-device-id
Password: your-api-key
Obtaining your API key
Login onto the OpenGate web interface
Click on the cogs that are at the top-right of the OpenGate home page
Click on the User option
Click on the “Click to show” link
Collecting data using mosquitto CLI tool
mosquitto is an open source MQTT client and server. The following example shows how to connect and publish data using OpenGate MQTT connector:
To subscribe to incoming operations from OpenGate: odm/request/your-device-id
To publish operation responses: odm/response/your-device-id
You have to replace your-device-id with the OpenGate unique identifier of your device.
Data collection payload
The payload definition in the section HTTP integration to collect data is entirely valid. You only have to add a "device": "your-device-id" field, filled with your OpenGate device unique identifier, at the top level of the JSON document with the collected values.
See the following example:
Publish to odm/iot/your-device-id topic this JSON:
Each example shows the complete flow of an operation over MQTT: the North API request that
creates the operation job, the request message the device receives on its
odm/request/your-device-id topic, and the response message the device publishes on its
odm/response/your-device-id topic.
You must be connected to OpenGate MQTT connector as a subscriber to topic odm/request/your-device-id,
if so, then you’ll receive an operation request like this:
Because this operation requests a full info refresh to your device, it must publish a new message with all the requested information to the topic odm/iot/your-device-id the message:
You must be connected to OpenGate MQTT connector as a subscriber to topic odm/request/your-device-id,
if so, then you’ll receive an operation request like this:
You must be connected to OpenGate MQTT connector as a subscriber to topic odm/request/your-device-id,
if so, then you’ll receive an operation request like this: