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:
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user