Updated decision making
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Pünkösd Marcell 2021-06-14 03:54:29 +02:00
parent 1f7f977e75
commit 5d83767d83
1 changed files with 7 additions and 2 deletions

View File

@ -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():