... | ... | @@ -194,6 +194,129 @@ This described how to push data using Device model into the HISTORIC DATA compon |
|
|
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.
|
|
|
|
|
|
The full documentation for this is at:
|
|
|
https://gitlab.distantaccess.com/naiades/naiades-platform-poc/-/wikis/rewriting-history
|
|
|
|
|
|
The API to be used for pushing this data, lives in another component than the CONTEXT MANAGER, as this one only handles real-time data. For this case we will use the HISTORIC DATA component API.
|
|
|
|
|
|
WIP |
|
|
\ No newline at end of file |
|
|
Before starting to push Device data into API we need to check that device exists in the platform, see `Creating the entity in the IoT platform` section.
|
|
|
|
|
|
Now, image that you have a data logger that logs temperature and soil_moisture , you have collected some sets and you want to make this data available through the IoT Platform.
|
|
|
Here below we show how to POST **A SINGLE ENTRY OF THE SET** for the date `"2020-10-21T16:16:16.00Z",` this is:
|
|
|
|
|
|
```bash
|
|
|
|
|
|
curl --location --request POST 'http://5.53.108.182:8668/v2/notify' \
|
|
|
--header 'Fiware-Service: carouge' \
|
|
|
--header 'Fiware-ServicePath: /' \
|
|
|
--header 'Content-Type: application/json' \
|
|
|
--data-raw '{
|
|
|
"subscriptionId": "5f8f0225da7e7c9ac9757a77",
|
|
|
"data": [
|
|
|
{
|
|
|
"id": "urn:ngsi-ld:Device:Device-test",
|
|
|
"type": "Device",
|
|
|
"value": {
|
|
|
"type": "Array",
|
|
|
"value": [
|
|
|
202.01,
|
|
|
1992
|
|
|
],
|
|
|
"metadata": {
|
|
|
"dateModified": {
|
|
|
"type": "DateTime",
|
|
|
"value": "2020-10-21T16:16:16.00Z"
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
"controlledProperty": {
|
|
|
"type": "Array",
|
|
|
"value": [
|
|
|
"soil_moisture",
|
|
|
"temperature"
|
|
|
],
|
|
|
"metadata": {
|
|
|
"dateModified": {
|
|
|
"type": "DateTime",
|
|
|
"value": "2020-10-21T16:16:16.00Z"
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
"location": {
|
|
|
"type": "geo:json",
|
|
|
"value": {
|
|
|
"type": "Point",
|
|
|
"coordinates": [
|
|
|
0.0,
|
|
|
0.0
|
|
|
]
|
|
|
},
|
|
|
"metadata": {
|
|
|
"dateModified": {
|
|
|
"type": "DateTime",
|
|
|
"value": "2020-10-21T16:16:16.00Z"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
}'
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
The date when the measurment was taken needs to be formatted as:
|
|
|
|
|
|
```json
|
|
|
"metadata": {
|
|
|
"dateModified": {
|
|
|
"type": "DateTime",
|
|
|
"value": "2020-10-21T16:16:16.00Z"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
```
|
|
|
All fields of the data model need to include this metadata, else, the current time will be used.
|
|
|
|
|
|
|
|
|
Getting all historical values of the Device
|
|
|
---------------------------------------------
|
|
|
|
|
|
```bash
|
|
|
curl --location --request GET 'http://5.53.108.182:8668/v2/entities/urn:ngsi-ld:Device:Device-test/attrs/value' \
|
|
|
--header 'Fiware-Service: carouge' \
|
|
|
--header 'Fiware-ServicePath: /'
|
|
|
|
|
|
This returns:
|
|
|
|
|
|
```bash
|
|
|
|
|
|
{
|
|
|
"attrName": "value",
|
|
|
"entityId": "urn:ngsi-ld:Device:Device-test",
|
|
|
"index": [
|
|
|
"2020-10-21T16:16:16.000",
|
|
|
"2020-11-12T11:41:43.000",
|
|
|
"2020-11-12T11:46:25.000",
|
|
|
"2020-11-12T12:04:04.000"
|
|
|
],
|
|
|
"values": [
|
|
|
[
|
|
|
"202.01",
|
|
|
"1992.0"
|
|
|
],
|
|
|
[
|
|
|
"0",
|
|
|
"1"
|
|
|
],
|
|
|
[
|
|
|
"17.5",
|
|
|
"30.0"
|
|
|
],
|
|
|
[
|
|
|
"40",
|
|
|
"122"
|
|
|
]
|
|
|
]
|
|
|
}
|
|
|
``` |
|
|
\ No newline at end of file |