fix mqtt recieve status
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
028313380f
commit
29837df3b2
@ -21,12 +21,10 @@ def handle_status_message(client, userdata, message):
|
|||||||
try:
|
try:
|
||||||
ids = data['topic'].replace(f"{config.MQTT_STATUS_TOPIC}/", "").split("/")
|
ids = data['topic'].replace(f"{config.MQTT_STATUS_TOPIC}/", "").split("/")
|
||||||
if len(ids) == 1:
|
if len(ids) == 1:
|
||||||
data['payload']['deviceID'] = ids[0]
|
app.logger.info(f"Recieved status message from {ids[0]} it was: {data['payload']}.")
|
||||||
app.logger.info(f"Recieved status message from {data['payload']['deviceID']}, persisting to db.")
|
|
||||||
else:
|
else:
|
||||||
if len(ids) == 2:
|
if len(ids) == 2:
|
||||||
data['payload']['deviceID'] = ids[0]
|
app.logger.info(
|
||||||
data['payload']['sensorID'] = ids[1]
|
f"Recieved status message from sensor {ids[1]} on device {ids[0]} it was: {data['payload']}.")
|
||||||
app.logger.info(f"Recieved status message from sensor {data['payload']['sensorID']}, persisting to db.")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
app.logger.exception(e)
|
app.logger.exception(e)
|
||||||
|
Loading…
Reference in New Issue
Block a user