Commit a42e5442 authored by Cédric Crettaz's avatar Cédric Crettaz 🖥

Update app.py for the unit of moisture.

parent ed62fe9c
......@@ -553,13 +553,14 @@ def get_model_device(deveui,
moist, bat = _get_reading(dataFrame)
body.update({'value': get_ngsiv2_typed_description(moist, meta_datetime)})
body.update({'batteryLevel': get_ngsiv2_typed_description(bat, meta_datetime)})
body.update({'moistureUnit': get_ngsiv2_typed_description('cb', meta_datetime)})
if deveui.startswith('a840') :
bat, moist, soil_temperature, conductivity = _get_reading_new(dataFrame)
body.update({'batteryLevel': get_ngsiv2_typed_description(bat, meta_datetime)})
body.update({'value': get_ngsiv2_typed_description(moist, meta_datetime)})
body.update({'soilTemperature': get_ngsiv2_typed_description(soil_temperature, meta_datetime)})
body.update({'soilMoistureEc': get_ngsiv2_typed_description(conductivity, meta_datetime)})
body.update({'moistureUnit': get_ngsiv2_typed_description('percent', meta_datetime)})
if dataFrame_rssi:
body.update({'rssi': get_ngsiv2_typed_description(dataFrame_rssi, meta_datetime)})
......@@ -586,7 +587,9 @@ def _update_flowerbed_entity(soil_moisture, sensor_eui):
app.logger.debug('Found FlowerBed {} associated to sensor {}'.format(flowerbed_id, sensor_eui))
body = {"soilMoisture": get_ngsiv2_typed_description(soil_moisture)}
body = {}
body.update({'soilMoisture': get_ngsiv2_typed_description(soil_moisture)})
body.update({'moistureUnit': get_ngsiv2_typed_description('cb')})
url = "{}/v2/entities/{}/attrs".format(URL_BASE, flowerbed_id)
r = client_request.patch(
url=url,
......@@ -629,6 +632,7 @@ def _update_flowerbed_entity_new(soil_moisture, soil_temperature, conductivity,
body.update({'soilMoisture': get_ngsiv2_typed_description(soil_moisture)})
body.update({'soilTemperature': get_ngsiv2_typed_description(soil_temperature)})
body.update({'soilMoistureEc': get_ngsiv2_typed_description(conductivity)})
body.update({'moistureUnit' : get_ngsiv2_typed_description('percent')})
url = "{}/v2/entities/{}/attrs".format(URL_BASE, flowerbed_id)
r = client_request.patch(
url=url,
......@@ -716,6 +720,7 @@ def _update_historical_db_from_local_raw_files():
'type': 'FlowerBed',
'soilMoisture': get_ngsiv2_typed_description(moist, json_data['timestamp']),
'refDevice': get_ngsiv2_typed_description(sensor_eui, json_data['timestamp']),
'moistureUnit': get_ngsiv2_typed_description('cb', json_data['timestamp']),
}
if sensor_eui.startswith('a840') :
_, moist, soil_temperature, conductivity = _get_reading_new(json_data['dataFrame'])
......@@ -726,6 +731,7 @@ def _update_historical_db_from_local_raw_files():
'soilTemperature': get_ngsiv2_typed_description(soil_temperature, json_data['timestamp']),
'soilMoistureEc': get_ngsiv2_typed_description(conductivity, json_data['timestamp']),
'refNewDevice': get_ngsiv2_typed_description(sensor_eui, json_data['timestamp']),
'moistureUnit': get_ngsiv2_typed_description('percent', json_data['timestamp']),
}
# add to list of data to be sent to quantum leap
......
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