Skip to content

Commit

Permalink
trackersync_topic
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH committed Dec 4, 2024
1 parent 3e7743b commit 1671654
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions TheengsGateway/ble_gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions TheengsGateway/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"whitelist": [],
"blacklist": [],
"enable_multi_gtw_sync": 1,
"trackersync_topic": "home/internal/trackersync",
}


Expand Down Expand Up @@ -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()


Expand Down
2 changes: 1 addition & 1 deletion TheengsGateway/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1671654

Please sign in to comment.