fix mqtt recieve status
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2021-06-12 20:06:18 +02:00
parent 028313380f
commit 29837df3b2
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047

View File

@ -21,12 +21,10 @@ def handle_status_message(client, userdata, message):
try:
ids = data['topic'].replace(f"{config.MQTT_STATUS_TOPIC}/", "").split("/")
if len(ids) == 1:
data['payload']['deviceID'] = ids[0]
app.logger.info(f"Recieved status message from {data['payload']['deviceID']}, persisting to db.")
app.logger.info(f"Recieved status message from {ids[0]} it was: {data['payload']}.")
else:
if len(ids) == 2:
data['payload']['deviceID'] = ids[0]
data['payload']['sensorID'] = ids[1]
app.logger.info(f"Recieved status message from sensor {data['payload']['sensorID']}, persisting to db.")
app.logger.info(
f"Recieved status message from sensor {ids[1]} on device {ids[0]} it was: {data['payload']}.")
except Exception as e:
app.logger.exception(e)