diff --git a/TheengsGateway/discovery.py b/TheengsGateway/discovery.py index aa909797..fcba1848 100644 --- a/TheengsGateway/discovery.py +++ b/TheengsGateway/discovery.py @@ -258,7 +258,8 @@ def publish_device_tracker( def copy_pub_device(self, device: dict) -> dict: """Copy pub_device and remove "track" if publish_advdata is false.""" # Remove "track" if PUBLISH_ADVDATA is 0 - if not self.configuration["publish_advdata"] and "track" in device: - device.pop("track", None) + pub_device_copy = device.copy() + if not self.configuration["publish_advdata"] and "track" in pub_device_copy: + pub_device_copy.pop("track", None) - return device + return pub_device_copy