This commit is contained in:
		@@ -53,9 +53,13 @@ def setup_rabbit() -> None:
 | 
			
		||||
 | 
			
		||||
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")
 | 
			
		||||
    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")
 | 
			
		||||
        mqtt.publish(subtopic=r.json()['device_id'],
 | 
			
		||||
                     message=json.dumps({"command": "doAlert"}))
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user