From 1671654bae6249ef92c92db7958b0484b6ba4eb5 Mon Sep 17 00:00:00 2001 From: DigiH Date: Tue, 29 Oct 2024 20:30:56 +0100 Subject: [PATCH] trackersync_topic --- TheengsGateway/ble_gateway.py | 6 +++--- TheengsGateway/config.py | 7 +++++++ TheengsGateway/discovery.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/TheengsGateway/ble_gateway.py b/TheengsGateway/ble_gateway.py index ac29932..f0ce6e3 100644 --- a/TheengsGateway/ble_gateway.py +++ b/TheengsGateway/ble_gateway.py @@ -153,7 +153,7 @@ def on_connect( ) self.subscribe(self.configuration["subscribe_topic"]) if self.configuration["enable_multi_gtw_sync"]: - self.subscribe("home/internal/trackersync") + self.subscribe(self.configuration["trackersync_topic"]) else: logger.error( "Failed to connect to MQTT broker %s:%d reason code: %s", @@ -231,7 +231,7 @@ def subscribe(self, sub_topic: str) -> None: def on_message(client, userdata, msg) -> None: # noqa: ANN001,ARG001 # Evaluate trackersync messages if ( - msg.topic == "home/internal/trackersync" + msg.topic == self.configuration["trackersync_topic"] and self.configuration["enable_multi_gtw_sync"] ): msg_json = json.loads(msg.payload) @@ -657,7 +657,7 @@ def publish_json( ) self.publish( message, - "home/internal/trackersync", + self.configuration["trackersync_topic"], ) logger.debug("[GP] Discovered Trackers: %s", self.discovered_trackers) diff --git a/TheengsGateway/config.py b/TheengsGateway/config.py index e3d5a49..5c62d38 100644 --- a/TheengsGateway/config.py +++ b/TheengsGateway/config.py @@ -52,6 +52,7 @@ "whitelist": [], "blacklist": [], "enable_multi_gtw_sync": 1, + "trackersync_topic": "home/internal/trackersync", } @@ -275,6 +276,12 @@ def parse_args() -> argparse.Namespace: type=int, help="Disable (0) or enable (1) to use tracker and closest control devices sync across Theengs Gateway gateways and OpenMQTTGateway (default: 1)", # noqa: E501 ) + parser.add_argument( + "-tt", + "--trackersync_topic", + type=str, + help="Internal trackersync publish topic", + ) return parser.parse_args() diff --git a/TheengsGateway/discovery.py b/TheengsGateway/discovery.py index 6cb0fca..437f747 100644 --- a/TheengsGateway/discovery.py +++ b/TheengsGateway/discovery.py @@ -284,7 +284,7 @@ def copy_pub_device(self, device: dict) -> dict: ) self.publish( message, - "home/internal/trackersync", + self.configuration["trackersync_topic"], ) logger.debug(" Discovered Trackers: %s", self.discovered_trackers)