... | ... | @@ -14,77 +14,114 @@ If you have deployed the IoT platform on your own, then use the correct IP of th |
|
|
|
|
|
Create the entity Flowerbed number x:
|
|
|
|
|
|
for more see `watering_01_create_entity.sh`
|
|
|
|
|
|
```bash
|
|
|
>> ./watering_01_create_entity.sh
|
|
|
Querying context broker at: 5.53.108.182
|
|
|
HTTP/1.1 100 Continue
|
|
|
curl -iX POST \
|
|
|
"http://$ORION_HOST:1026/v2/entities/?options=keyValues" \
|
|
|
--header "Fiware-Service: carouge" \
|
|
|
--header "Content-Type: application/json" \
|
|
|
--data '{
|
|
|
"id": "urn:ngsi-ld:FlowerBed:FlowerBed-2",
|
|
|
"type": "FlowerBed",
|
|
|
"dateLastWatering": {
|
|
|
"type": "DateTime",
|
|
|
"value": "1970-01-01T01:00:00.00Z",
|
|
|
},
|
|
|
"flowerType": {
|
|
|
"value": "Perennial",
|
|
|
},
|
|
|
"location": {
|
|
|
"type": "geo:json",
|
|
|
"value": {
|
|
|
"coordinates": [
|
|
|
6.13397,
|
|
|
46.18261
|
|
|
],
|
|
|
"type": "Point"
|
|
|
},
|
|
|
},
|
|
|
"nextWateringAmountRecommendation": {
|
|
|
"value": 0.5,
|
|
|
|
|
|
},
|
|
|
"nextWateringDeadline": {
|
|
|
"value": "2020-10-27T14:59:16UTC",
|
|
|
},
|
|
|
"refDevice": {
|
|
|
"value": "0018b20000020a35",
|
|
|
},
|
|
|
"soilMoisture": {
|
|
|
"value": 0,
|
|
|
},
|
|
|
"sunExposure": {
|
|
|
"value": "Mid shadow",
|
|
|
}
|
|
|
}'
|
|
|
|
|
|
HTTP/1.1 201 Created
|
|
|
Connection: Keep-Alive
|
|
|
Content-Length: 0
|
|
|
Location: /ngsi-ld/v1/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1
|
|
|
Date: Tue, 12 May 2020 11:32:28 GMT
|
|
|
|
|
|
```
|
|
|
|
|
|
## Retrieve all `entity`s
|
|
|
|
|
|
Get all entities, note that the response includes `type` information, which is quite verbose and harder to parse if not using a dedicated library for doing so:
|
|
|
for more see `script watering_02_retrieve_entities.sh`
|
|
|
|
|
|
Get all entities, note that the response includes `type` information"
|
|
|
|
|
|
```bash
|
|
|
|
|
|
curl --location --request GET \
|
|
|
"http://$ORION_HOST:1026/v2/entities/" \
|
|
|
--header "Fiware-Service: carouge" \
|
|
|
| python -mjson.tool
|
|
|
|
|
|
```
|
|
|
|
|
|
which returns something like this:
|
|
|
|
|
|
```bash
|
|
|
>> ./watering_02_retrieve_entities.sh
|
|
|
Querying context broker at: 5.53.108.182
|
|
|
% Total % Received % Xferd Average Speed Time Time Time Current
|
|
|
Dload Upload Total Spent Left Speed
|
|
|
100 649 100 649 0 0 16508 0 --:--:-- --:--:-- --:--:-- 16641
|
|
|
[
|
|
|
{
|
|
|
{
|
|
|
"id": "urn:ngsi-ld:FlowerBed:FlowerBed-7",
|
|
|
"location": {
|
|
|
"metadata": {},
|
|
|
"type": "geo:json",
|
|
|
"value": {
|
|
|
"type": "Point",
|
|
|
"coordinates": [
|
|
|
0,
|
|
|
0
|
|
|
]
|
|
|
],
|
|
|
"type": "Point"
|
|
|
}
|
|
|
},
|
|
|
"category": {
|
|
|
"metadata": {},
|
|
|
"type": "StructuredValue",
|
|
|
"value": [
|
|
|
"urbanTreeSpot"
|
|
|
]
|
|
|
},
|
|
|
"dateLastWatering": {
|
|
|
"nextWateringAmountRecommendation": {
|
|
|
"metadata": {},
|
|
|
"type": "DateTime",
|
|
|
"value": "2017-03-31T08:00"
|
|
|
"value": "1970-01-01T01:00:00.00Z"
|
|
|
},
|
|
|
"dateModified": {
|
|
|
"nextWateringDeadline": {
|
|
|
"metadata": {},
|
|
|
"type": "DateTime",
|
|
|
"value": "2017-03-31T08:00"
|
|
|
"type": "Text",
|
|
|
"value": "2020-10-23T14:59:16UTC"
|
|
|
},
|
|
|
"id": "urn:ngsi-ld:FlowerBed:FlowerBed-1",
|
|
|
"nextWateringDeadline": {
|
|
|
"refDevice": {
|
|
|
"metadata": {},
|
|
|
"type": "Text",
|
|
|
"value": "2017-04-31T08:00"
|
|
|
"value": "None"
|
|
|
},
|
|
|
"soilMoistureVwc": {
|
|
|
"soilMoisture": {
|
|
|
"metadata": {},
|
|
|
"type": "Number",
|
|
|
"value": 0.85
|
|
|
"value": 0
|
|
|
},
|
|
|
"soilTemperature": {
|
|
|
"sunExposure": {
|
|
|
"metadata": {},
|
|
|
"type": "Number",
|
|
|
"value": 17
|
|
|
"type": "Text",
|
|
|
"value": "Mid shadow"
|
|
|
},
|
|
|
"type": "FlowerBed"
|
|
|
}
|
|
|
]
|
|
|
(...)
|
|
|
```
|
|
|
|
|
|
**In the following we propose a simpler type-less query, to be used just when you do a GET (if you push data using keyValues then the types of the attributes are overwritten to TEXT type, not good!)**
|
... | ... | |