Commit 5ef0fe35 authored by Federico Sismondi's avatar Federico Sismondi
Browse files

Now Device entities attrs are rewritten

parent 86d6d499
......@@ -307,7 +307,7 @@ def get_model_device(deveui,
body = {}
app.logger.info('Creating/Updating devices in CTX broker for deveui {}'.format(deveui))
app.logger.info('Generating data model for {}{}'.format(URN_BASE_DEVICE_ENTITY, deveui[-4:]))
# static values
body.update({'id': '{}{}'.format(URN_BASE_DEVICE_ENTITY, deveui[-4:])})
......@@ -539,7 +539,7 @@ def _create_device_entity(deveui, comment, longitude, latitude, last_reception,
dataFrame_rssi,
dataFrame_timestamp)
app.logger.debug('Sending data to CTX broker: {}'.format(body))
app.logger.debug('CREATING entity in CTX broker: {}'.format(body))
url = "{}/v2/entities/".format(URL_BASE)
r = client_request.post(
......@@ -559,8 +559,8 @@ def _create_device_entity(deveui, comment, longitude, latitude, last_reception,
return "ok"
def _patch_device_entity(deveui, comment, longitude, latitude, last_reception, dataFrame, dataFrame_rssi,
dataFrame_timestamp):
def _rewrite_device_attributes(deveui, comment, longitude, latitude, last_reception, dataFrame, dataFrame_rssi,
dataFrame_timestamp):
"""Updates LoRa devs into ctx broker
"""
assert deveui
......@@ -580,9 +580,9 @@ def _patch_device_entity(deveui, comment, longitude, latitude, last_reception, d
body.pop('id') # we don't need this for a PATCH
body.pop('type') # we don't need this for a PATCH
app.logger.debug('Sending data to CTX broker: {}'.format(body))
url = "{}/v2/entities/{}/attrs?options=append".format(URL_BASE, entity_id)
r = client_request.post(
app.logger.debug('PATCHING data in CTX broker: {}'.format(body))
url = "{}/v2/entities/{}".format(URL_BASE, entity_id)
r = client_request.put(
url=url,
headers=http_header_post,
json=body
......@@ -656,12 +656,8 @@ def post_dca_carouge_watering_sensed_data_payload():
soil_humidity,
sensor_eui
)})
resp.update({"update_device_entities": _patch_device_entity(
resp.update({"update_device_entities": _rewrite_device_attributes(
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']
......
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