diff --git a/src/app.py b/src/app.py index 3fdf75d..b9fc000 100644 --- a/src/app.py +++ b/src/app.py @@ -64,11 +64,15 @@ def on_message_creator(mqtt_: MQTT): msg_json = json.loads(body) if 'probability' not in msg_json: logging.error("Malformed message from broker") + return + if msg_json['probability'] > 0.5: r = requests.get(f"http://{config.INPUT_HOSTNAME}/sample/{msg_json['tag']}") r.raise_for_status() if 'device_id' not in r.json(): logging.error("Input-service response invalid") + return + logging.info(f"Sending alert command to device {r.json()['device_id']}") mqtt_.publish(subtopic=r.json()['device_id'], message=json.dumps({"command": "doAlert"}))