diff --git a/TheengsGateway/ble_gateway.py b/TheengsGateway/ble_gateway.py index 455e5274..bc0b46c3 100644 --- a/TheengsGateway/ble_gateway.py +++ b/TheengsGateway/ble_gateway.py @@ -460,12 +460,9 @@ def decode_advertisement( if decoded_json: decoded_json = json.loads(decoded_json) - if "prmac" in decoded_json: - address = decoded_json.get("id") - if address in self.configuration["identities"]: - decoded_json.pop("prmac", None) - else: - decoded_json["type"] = "RMAC" + decoded_json = self.process_prmacs( + decoded_json, + ) # Only process if the device is not a random mac address if decoded_json["type"] != "RMAC": @@ -501,6 +498,20 @@ def decode_advertisement( add_manufacturer(data_json, company_id) self.publish_json(data_json, decoded=False) + def process_prmacs( + self, + decoded_json: DataJSONType, + ) -> DataJSONType: + """Process potential RMACs.""" + if "prmac" in decoded_json: + address = decoded_json.get("id") + if address in self.configuration["identities"]: + decoded_json.pop("prmac", None) + else: + decoded_json["type"] = "RMAC" + + return decoded_json + def publish_json( self, data_json: DataJSONType,