From 5d83767d83e983b14ec49046f7eae18127b67e8e Mon Sep 17 00:00:00 2001 From: marcsello Date: Mon, 14 Jun 2021 03:54:29 +0200 Subject: [PATCH] Updated decision making --- src/app.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/app.py b/src/app.py index b9fc000..ce59acd 100644 --- a/src/app.py +++ b/src/app.py @@ -63,10 +63,15 @@ def on_message_creator(mqtt_: MQTT): def on_message(channel, method_frame, header_frame, body): msg_json = json.loads(body) if 'probability' not in msg_json: - logging.error("Malformed message from broker") + logging.error("Malformed message from classifier") return - if msg_json['probability'] > 0.5: + if 'class' not in msg_json: + logging.error("Malformed message from classifier") + return + + # TODO: strurnus should not be hardcoded here + if (msg_json['class'] == 'sturnus') and (msg_json['probability'] > 0.51): r = requests.get(f"http://{config.INPUT_HOSTNAME}/sample/{msg_json['tag']}") r.raise_for_status() if 'device_id' not in r.json():