Commit ba0a4ce0 authored by Federico Sismondi's avatar Federico Sismondi

Updates logged info

parent 78a42ed2
...@@ -144,6 +144,7 @@ def _log_level_of_moisture(cb, sensor): ...@@ -144,6 +144,7 @@ def _log_level_of_moisture(cb, sensor):
else: else:
app.logger.error("Measurement not in expected range: {} cb".format(cb)) app.logger.error("Measurement not in expected range: {} cb".format(cb))
def _log_level_of_battery_level(bat, sensor): def _log_level_of_battery_level(bat, sensor):
if bat < 0.5: if bat < 0.5:
...@@ -256,15 +257,16 @@ def _update_flowerbed_entity(soil_moisture, sensor_eui): ...@@ -256,15 +257,16 @@ def _update_flowerbed_entity(soil_moisture, sensor_eui):
app.logger.debug('Found FlowerBed {} associated to sensor {}'.format(flowerbed_id, sensor_eui)) app.logger.debug('Found FlowerBed {} associated to sensor {}'.format(flowerbed_id, sensor_eui))
body = {"soilMoisture": get_ngsiv2_typed_description(soil_moisture)}
url = "{}/v2/entities/{}/attrs".format(URL_BASE, flowerbed_id) url = "{}/v2/entities/{}/attrs".format(URL_BASE, flowerbed_id)
r = client_request.patch( r = client_request.patch(
url=url, url=url,
headers=http_header_post, headers=http_header_post,
json={ json=body
"soilMoisture": get_ngsiv2_typed_description(soil_moisture)
}
) )
app.logger.debug('Sending data to CTX broker: {}'.format(body))
if not (200 <= r.status_code < 300): if not (200 <= r.status_code < 300):
app.logger.error('HTTP status code not 2xx, something went wrong..') app.logger.error('HTTP status code not 2xx, something went wrong..')
app.logger.error(r.status_code) app.logger.error(r.status_code)
...@@ -272,7 +274,7 @@ def _update_flowerbed_entity(soil_moisture, sensor_eui): ...@@ -272,7 +274,7 @@ def _update_flowerbed_entity(soil_moisture, sensor_eui):
app.logger.error(r.json()) app.logger.error(r.json())
return "Got error {}".format(r.reason) return "Got error {}".format(r.reason)
else: else:
app.logger.info('HTTP response is {} - Entity updated'.format(r.status_code)) app.logger.info('Entity updated (code {}), url {}'.format(r.status_code, url))
return "ok" return "ok"
...@@ -352,7 +354,6 @@ def _update_device_entity(deveui, comment, longitude, latitude, last_reception, ...@@ -352,7 +354,6 @@ def _update_device_entity(deveui, comment, longitude, latitude, last_reception,
body.update({'value': get_ngsiv2_typed_description(moist)}) body.update({'value': get_ngsiv2_typed_description(moist)})
body.update({'batteryLevel': get_ngsiv2_typed_description(bat)}) body.update({'batteryLevel': get_ngsiv2_typed_description(bat)})
if dataFrame_rssi: if dataFrame_rssi:
body.update({'rssi': get_ngsiv2_typed_description(dataFrame_rssi)}) body.update({'rssi': get_ngsiv2_typed_description(dataFrame_rssi)})
...@@ -372,7 +373,7 @@ def _update_device_entity(deveui, comment, longitude, latitude, last_reception, ...@@ -372,7 +373,7 @@ def _update_device_entity(deveui, comment, longitude, latitude, last_reception,
app.logger.error(r.json()) app.logger.error(r.json())
return "Got error {}".format(r.reason) return "Got error {}".format(r.reason)
else: else:
app.logger.info('HTTP response is {} - Entity updated'.format(r.status_code)) app.logger.info('Entity updated (code {}), url {}'.format(r.status_code, url))
return "ok" return "ok"
......
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