Commit 86d6d499 authored by Federico Sismondi's avatar Federico Sismondi
Browse files

Fix now we rewrite carouge Devices entities at startup

parent 5d5d9ed3
......@@ -581,13 +581,12 @@ def _patch_device_entity(deveui, comment, longitude, latitude, last_reception, d
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".format(URL_BASE, entity_id)
r = client_request.patch(
url = "{}/v2/entities/{}/attrs?options=append".format(URL_BASE, entity_id)
r = client_request.post(
url=url,
headers=http_header_post,
json=body
)
if not (200 <= r.status_code < 300):
app.logger.error('HTTP status code not 2xx, something went wrong..')
app.logger.error(r.status_code)
......@@ -696,6 +695,13 @@ def init():
# push data to CTX broker
for i in lora_nodes_info:
# delete first so we start from scratch (no one besides us touches these entities)
client_request.delete(
url='{}/v2/entities/{}{}'.format(URL_BASE, URN_BASE_DEVICE_ENTITY,i['deveui'][-4:]),
headers=http_header_get
)
_create_device_entity(
deveui=i['deveui'],
comment=i['comment'],
......
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