Commit 68dead80 authored by Cédric Crettaz's avatar Cédric Crettaz 🖥

Correction of a bug concerning the timestamp in DCA Carouge fountain.

parent 9de0718c
......@@ -75,6 +75,8 @@ def get_ngsiv2_typed_description(val, force_date_modified=None):
)
if force_date_modified and isinstance(force_date_modified, str):
# adds datetime metadata
force_date_modified = force_date_modified + "Z"
force_date_modified = force_date_modified.replace(" ", "T")
ret.update(
{"metadata":
{"dateModified": {"type": "DateTime", "value": force_date_modified}}
......@@ -219,6 +221,10 @@ def get_model_water_quality_observed(
'location'
]
# Handle the timestamp
meta_datetime = meta_datetime.replace("T", " ")
meta_datetime = meta_datetime.replace("Z", "")
for v in values:
key = v
val = locals()[v] # gets var value from var name
......@@ -346,6 +352,7 @@ def _update_fountain_entity(sensor_dataFrame, timestamp):
entity = get_model_water_quality_observed(
turbidity=values[0] / 10,
dateObserved=timestamp,
meta_datetime=timestamp,
)
elif len(values) == 5: # this is the device with 5 sensors
......@@ -356,6 +363,7 @@ def _update_fountain_entity(sensor_dataFrame, timestamp):
totalChlorine=values[3] / 100 if values[3] else None, # in mg/L
redox=values[4] / 1000 if values[4] else None, # in volts
dateObserved=timestamp,
meta_datetime=timestamp,
)
else:
raise InvalidUsage(
......@@ -375,7 +383,7 @@ def _update_fountain_entity(sensor_dataFrame, timestamp):
)
# Debug for JSON frame
app.logger.info('JSON: {}'.format(entity))
app.logger.info(entity)
if not (200 <= r.status_code < 300):
app.logger.error('HTTP status code not 2xx, something went wrong..')
......
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