Commit dcc0eb0d authored by Federico Sismondi's avatar Federico Sismondi

Merge branch 'scripts_for_pushing_local_data_to_cloud' into 'master'

Scripts for pushing local data to cloud

See merge request !18
parents 5fb0753e d69679d0
This diff is collapsed.
......@@ -370,20 +370,23 @@ def post_dca_carouge_watering_sensed_data_payload():
# log reading
_log_level_of_moisture(soil_humidity, sensor_eui)
# push data to context broker
# saves locally and pushed data to FlowerBed and Device entities
resp = {}
resp.update({"fs_dump": _dump_raw_data_to_filesystem()})
resp.update({"update_flowerbed_entities": _update_flowerbed_entity(soil_humidity, sensor_eui)})
# resp.update({"update_device_entities": _update_device_entity(
# deveui=request.json['deveui'],
# comment=None,
# longitude=None,
# latitude=None,
# last_reception=None,
# dataFrame=request.json['dataFrame'],
# dataFrame_rssi=request.json['rssi'],
# dataFrame_timestamp=request.json['timestamp']
# )})
resp.update({"update_flowerbed_entities": _update_flowerbed_entity(
soil_humidity,
sensor_eui
)})
resp.update({"update_device_entities": _update_device_entity(
deveui=request.json['deveui'],
comment=None,
longitude=None,
latitude=None,
last_reception=None,
dataFrame=request.json['dataFrame'],
dataFrame_rssi=request.json['rssi'],
dataFrame_timestamp=request.json['timestamp']
)})
return resp
......
......@@ -3,7 +3,7 @@
FROM python:3.8-slim-buster
MAINTAINER Federico Sismondi <fsismondi@udgalliance.org>
RUN apt-get update
RUN apt-get update && apt install unzip
RUN mkdir /code
WORKDIR /code
......@@ -12,6 +12,7 @@ COPY requirements.txt requirements.txt
RUN pip install --timeout 300 -r requirements.txt
COPY . /code
RUN unzip /code/data_harmonization_tool.zip
CMD ["echo", "please override this CMD with some .sh or .py script call"]
# docker run -it --rm --name dca-carouge-weather --env ORION_HOST=10.81.6.109 naiades-client ./weather_02_get_all_raw_data.py
......
......@@ -41,7 +41,9 @@ def get_ngsiv2_typed_description(val):
return {'type': 'Text', 'value': new_val}
elif isinstance(val, datetime):
# replace +00:00 is the same as Z but Orion doesnt like it :/
return {'type': 'DateTime', 'value': str(val.isoformat()).replace("+00:00", "Z")}
timestamp = str(val.isoformat()).replace("+00:00", "Z")
print("rewriting timestamp to {}".format(timestamp))
return {'type': 'DateTime', 'value': timestamp}
elif isinstance(val, dict):
return {'value': val} # bypassed
elif isinstance(val, list):
......@@ -116,8 +118,8 @@ attrs = {
entities = [
# prediction use case - weather observed (current)
('urn:ngsi-ld:WeatherObserved:WeatherObserved', ['carouge', 'braila']),
('urn:ngsi-ld:WeatherObserved:WeatherObserved-1', ['alicante']),
('urn:ngsi-ld:WeatherObserved:WeatherObserved-2', ['alicante']),
#('urn:ngsi-ld:WeatherObserved:WeatherObserved-1', ['alicante']),
#('urn:ngsi-ld:WeatherObserved:WeatherObserved-2', ['alicante']),
("urn:ngsi-ld:WaterQualityObserved:Fountain-1", ['carouge']),
......
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