Commit ba7a170b authored by Federico Sismondi's avatar Federico Sismondi

Updated() FlowerBed entity model regarding last discussions for Carouge DCA

parent 82425f51
......@@ -156,9 +156,9 @@ def _forward_lora_devs_metadata_to_ctx_broker(dev_eui, entity_id, location, oper
app.logger.info("Initializing IoT sensor meta (entity {})".format(entity_id))
url = "{}/v2/entities/{}/attrs".format(URL_BASE, entity_id)
payload = {
'boxId': {'value': entity_id.split('-')[-1]},
'moistureDeviceEui': {'value': dev_eui},
'boxOperatorComment': {'value': operator_comment},
#'boxId': {'value': entity_id.split('-')[-1]},
'refDevice': {'value': dev_eui},
#'boxOperatorComment': {'value': operator_comment},
'location': {'type': 'geo:json', 'value': {'coordinates': location, 'type': 'Point'}},
}
......
......@@ -72,10 +72,7 @@ extra_args = {
'nextWateringDeadline': datetime.fromtimestamp(0),
'nextWateringAmountRecommendation': datetime.fromtimestamp(0),
'soilMoisture': 0.0,
'moistureDeviceEui': None,
'boxId': None,
'boxSize': None,
'boxOperatorComment': '',
'refDevice': None,
}
}
......@@ -137,9 +134,15 @@ for urn, pilots in entities:
**{attr_n: get_ngsiv2_typed_description(attr_v) for attr_n, attr_v in
extra_args[data_type].items()}
})
except KeyError:
raise KeyError('Unrecognized pilot {}'.format(pilot))
# for _, ents in entities_map.items():
# pprint(ents, indent=4)
#import sys
#sys.exit(0)
# create entities in IoT platform
print('Updating/creating entities')
......
......@@ -4,7 +4,7 @@
echo "Querying QuantumLeap API at: ${QUANTUM_HOST}"
curl --location --request GET \
"http://$QUANTUM_HOST:8668/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoisture/value?limit=100" \
"http://$QUANTUM_HOST:8668/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoisture/value?lastN=100" \
--header "Fiware-Service: carouge" \
--header "Fiware-ServicePath: /" \
--header "Accept: application/json"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment