Commit 542281dc authored by Federico Sismondi's avatar Federico Sismondi
Browse files

Add entities for water quality forecasts (carouge and wtp_lab)

parent 6f16d072
......@@ -110,7 +110,28 @@ attrs = {
'phThresholdLow': 0.0,
'chlorineThresholdHigh': 0.0,
'chlorineThresholdLow': 0.0,
}
},
"FountainUsageObserved": {
'dateObserved': datetime.utcnow(), # mandatory
'location': Point([0, 0]), # mandatory
'peopleInFountain': 0,
'petsInFountain': 0,
},
"WaterQualityForecast": {
'validFrom': datetime.fromtimestamp(0), # mandatory
'validTo': datetime.fromtimestamp(0), # mandatory
'location': Point([0, 0]), # mandatory
'chlorinationDosageRecommendation': 0.0,
'coagulantDosageRecommendation': 0.0,
'filtrationTimeRecommendation': 0.0,
'pHPrediction': 0.0,
'totalChlorinePrediction': 0.0,
'freeChlorinePrediction': 0.0,
'turbidityPrediction': 0.0,
'conductivityPrediction': 0.0,
'chloratePrediction': 0.0,
},
}
# entities ids per pilot tuples
......@@ -147,13 +168,17 @@ entities = [
# water quality use cases
("urn:ngsi-ld:WaterQualityObserved:Fountain-1", ['carouge']),
("urn:ngsi-ld:FountainUsageObserved:Fountain-1", ['carouge']),
("urn:ngsi-ld:WaterQualityForecast:Fountain-1", ['carouge']),
("urn:ngsi-ld:WaterQualityObserved:WaterTreatmentPlant", ['wtp_lab']),
("urn:ngsi-ld:WaterQualityForecast:WaterTreatmentPlant", ['wtp_lab']),
]
# http headers
headers = {
'Fiware-Service': None, # UPDATE this before sending request!
'Fiware-Service': None, # UPDATE this before sending request!
'Content-Type': 'application/json'
}
......@@ -190,13 +215,13 @@ for urn, pilots in entities:
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description='Create entities for pilot in IoT Platform.',
description='Create entities for pilot in IoT Platform.',
)
parser.add_argument('pilot', help='Pilot name to update')
args = parser.parse_args(sys.argv[1:2])
if args.pilot not in entities_map.keys():
print('Unrecognized pilot, options:{} '.format( list(entities_map.keys())))
print('Unrecognized pilot, options:{} '.format(list(entities_map.keys())))
exit(1)
# create entities in IoT platform
......@@ -205,16 +230,16 @@ if __name__ == "__main__":
# log created entities
entities = entities_map[args.pilot]
print('Number of entities to be created for {}: {}'.format(args.pilot, len(entities )))
print('Number of entities to be created for {}: {}'.format(args.pilot, len(entities)))
headers['Fiware-Service'] = args.pilot
operation = {
'actionType': 'append',
'entities': entities
'actionType': 'append',
'entities': entities
}
print('*' * 72)
print('Service {} entities:'.format(args.pilot))
pprint([i['id'] for i in entities ])
pprint([i['id'] for i in entities])
print('*' * 72)
r = requests.post(url=URL_BASE + '/v2/op/update', headers=headers, json=operation)
......
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