|
|
This document explains how to push data from City Pilots to IoT Platform.
|
|
|
Basically it covers 3 things:
|
|
|
|
|
|
1. How we can use Device data model for IoT devices in pilots.
|
|
|
2. How to push `real-time` data to IoT Platform.
|
|
|
3. How to push `locally collected` (e.g. scada or data loggers) data to IoT Platform.
|
|
|
1. How we can use `Device data model` for IoT devices in pilots.
|
|
|
2. How to push `real-time` Device data to IoT Platform.
|
|
|
3. How to push `locally collected` (e.g. scada or data loggers) Device data to IoT Platform.
|
|
|
|
|
|
|
|
|
Before starting to describe Device data model, you should ask yourself:
|
... | ... | @@ -37,7 +37,7 @@ For this, the proposal is to use create a Device entity in the following way: |
|
|
```
|
|
|
|
|
|
{
|
|
|
"id": "urn:ngsi-ld:Device:Device-1",
|
|
|
"id": "urn:ngsi-ld:Device:Device-test",
|
|
|
"type": "Device",
|
|
|
"value": {
|
|
|
"type": "Array",
|
... | ... | @@ -69,10 +69,10 @@ Discussion |
|
|
----------
|
|
|
This model is simple, and flexible, as we can include any sensed data we want in the device entity.
|
|
|
On the other side, there is an added complexity for the consumers, and they dont know which attributes are included in an entity until they got fetch the data. This is not the case for example for a WeatherObserved entity, as we always know that these kind of entityes always have an attribute describing e.g. the temperature.
|
|
|
To overcome this added complexity this document describes how to use the NGSIv2 powerful querying mechanisms and getting the data you want efficiently, without having to do too much filtering.
|
|
|
|
|
|
Creating the entity in the IoT platform
|
|
|
---------------------------------------
|
|
|
If the entity was not created already by the UDGA team you should contact them before doing so.
|
|
|
|
|
|
As an example, you can create an entity using bash:
|
|
|
|
... | ... | @@ -85,11 +85,11 @@ curl --location --request POST 'http://5.53.108.182:1026/v2/entities/' \ |
|
|
"type": "Device",
|
|
|
"value": {
|
|
|
"type": "Array",
|
|
|
"value":[0.0,1]
|
|
|
"value":[17.5,30]
|
|
|
},
|
|
|
"controlledProperty": {
|
|
|
"type": "Array",
|
|
|
"value": ["soil_moisture","temperature"]
|
|
|
"value": ["temperature","soil_moisture"]
|
|
|
},
|
|
|
"location": {
|
|
|
"type": "geo:json",
|
... | ... | @@ -102,14 +102,98 @@ curl --location --request POST 'http://5.53.108.182:1026/v2/entities/' \ |
|
|
}
|
|
|
}
|
|
|
}
|
|
|
'
|
|
|
```
|
|
|
|
|
|
Consumers of Device entity
|
|
|
--------------------------
|
|
|
If you know specifically which device you want data from:
|
|
|
|
|
|
```bash
|
|
|
curl --location --request GET 'http://5.53.108.182:1026/v2/entities/urn:ngsi-ld:Device:Device-test' \
|
|
|
--header 'Fiware-Service: carouge'
|
|
|
```
|
|
|
|
|
|
When trying to get all devices in carouge which sense soil_moisture, you can:
|
|
|
|
|
|
```bash
|
|
|
curl --location --request GET 'http://5.53.108.182:1026/v2/entities?type=Device&q=controlledProperty==soil_moisture&limit=100' \
|
|
|
--header 'Fiware-Service: carouge'
|
|
|
```
|
|
|
|
|
|
in this case `q=controlledProperty==soil_moisture` provides us with the filtering features we want. Other attributes could be used for extending the filtering features.
|
|
|
|
|
|
|
|
|
If you want to know how to get the historical values of a certain value please keep reading.
|
|
|
|
|
|
# 2. How to push `real-time` Device data to IoT Platform.
|
|
|
|
|
|
This described how to push data using Device model into the CONTEXT MANAGER (real-time data).
|
|
|
|
|
|
If you read section 1. you know there is an entity called `urn:ngsi-ld:Device:Device-test` in the IoT Platform.
|
|
|
Now suppose we have collected a new value for temperature and soil_moisture, and hence we want to update those values.
|
|
|
We may want to update a certain attribute temperature, or soil_moisture, or both.
|
|
|
For this we could simply update the Device.value like this:
|
|
|
|
|
|
```bash
|
|
|
curl --location --request PUT 'http://5.53.108.182:1026/v2/entities/urn:ngsi-ld:Device:Device-test/attrs/value' \
|
|
|
--header 'Fiware-Service: carouge' \
|
|
|
--header 'Content-Type: application/json' \
|
|
|
--data-raw '{
|
|
|
"type": "Array",
|
|
|
"value": [
|
|
|
40.0,
|
|
|
122
|
|
|
]
|
|
|
}
|
|
|
'
|
|
|
```
|
|
|
|
|
|
# 2. How to push `real-time` data to IoT Platform.
|
|
|
now if you consume again this entity data, you will get:
|
|
|
|
|
|
```bash
|
|
|
{
|
|
|
"id": "urn:ngsi-ld:Device:Device-test",
|
|
|
"type": "Device",
|
|
|
"controlledProperty": {
|
|
|
"type": "Array",
|
|
|
"value": [
|
|
|
"temperature",
|
|
|
"soil_moisture"
|
|
|
],
|
|
|
"metadata": {}
|
|
|
},
|
|
|
"location": {
|
|
|
"type": "geo:json",
|
|
|
"value": {
|
|
|
"type": "Point",
|
|
|
"coordinates": [
|
|
|
0,
|
|
|
0
|
|
|
]
|
|
|
},
|
|
|
"metadata": {}
|
|
|
},
|
|
|
"value": {
|
|
|
"type": "Array",
|
|
|
"value": [
|
|
|
40,
|
|
|
122
|
|
|
],
|
|
|
"metadata": {}
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
Et voilà! Your data is updated inside the context manager of the platform
|
|
|
|
|
|
# 3. How to push `locally collected` (e.g. scada or data loggers) Device data to IoT Platform.
|
|
|
|
|
|
This described how to push data using Device model into the HISTORIC DATA component (time series data).
|
|
|
|
|
|
You data is not real-time data, as you have collected it locally, and some time passed between that and now.
|
|
|
Also, you probably have more than one set of data, e.g. you may have collected data during the last 24 hours or more, taking samples every 15 mins.
|
|
|
|
|
|
|
|
|
# 3. How to push `locally collected` (e.g. scada or data loggers) data to IoT Platform.
|
|
|
|
|
|
WIP |
|
|
\ No newline at end of file |