This post shows how to use the OpenGate demo UDP connector.
Access data
Some UDP libraries and environments need domain name resolution. In those cases, api.opengate.es
must be previously resolved to its IP address. At the time of this document, the IP address for api.opengate.es
was 35.157.105.177
. Please check it before starting your test.
If you’re like me and are using a Linux machine, type nslookup
:
charlie@dune> nslookup api.opengate.es
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: api.opengate.es
Address: 35.157.105.177
- Host Name:
api.opengate.es
- Host IP:
35.157.105.177
- UDP Port:
10001
How to obtain your API key
In addition, you’ll need your API key. Once you login onto the OpenGate web interface, you can find your API key by clicking on the cogs at the top-right of the OpenGate home page, then on the User option, and finally on the “Click to show” link.
Payload
The payload definition available in the official OpenGate documentation is entirely valid for data publishing. You only have to add, at the top level of the JSON document, the following fields:
- a
"device": "your-device-id"
field, filled with your OpenGate device unique identifier. - a
"apikey": "your-api-key"
field, filled with your OpenGate API key.
See the following example:
This example shows how to send data points to two data streams:
entity.location
: this is one of the default data streams provided out of the box by OpenGate.temperature
: this is a custom data stream to send temperature.
{
"version": "1.0.0",
"device": "your-device-id",
"apikey": "your-api-key",
"datastreams": [
{
"id": "device.temperature.value",
"datapoints": [
{
"at": 1545129674,
"value": 23
}
]
},
{
"id": "entity.location",
"datapoints": [
{
"at": 1545129674,
"value": {
"position": {
"type": "Point",
"coordinates": [-3.6737821999999993, 40.4475705]
}
}
}
]
}
]
}