Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: derive service topic from topic_id #28

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions gittyup.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def __init__(self):
self.client = None
self.device_id = get_device_type()
self.root = get_topic_root_prefix()
self.service_root = "/".join(self.root.split("/")[0:3] + ["service", "gittyup"])
self.sub_topic = f"{self.root}/cmd/device_profile/+"

def connect(self):
Expand All @@ -91,7 +92,7 @@ def connect(self):
logger.debug(f"Trying to connect to the MQTT broker: host={host}:{port}")

client.will_set(
"te/device/main/service/gittyup/status/health",
f"{self.self.service_root}/status/health",
json.dumps({"status": "down"}),
qos=1,
retain=True,
Expand All @@ -105,7 +106,7 @@ def shutdown(self):
"""Shutdown client including any workers in progress"""
if self.client and self.client.is_connected():
self.client.publish(
"te/device/main/service/gittyup/status/health",
f"{self.self.service_root}/status/health",
json.dumps({"status": "down"}),
qos=1,
retain=True,
Expand Down Expand Up @@ -136,7 +137,7 @@ def on_connect(self, client, userdata, flags, reason_code):
else:
logger.info(f"Connected to MQTT broker! result_code={reason_code}")
client.publish(
"te/device/main/service/gittyup/status/health",
f"{self.service_root}/status/health",
json.dumps({"status": "up"}),
retain=True,
qos=1,
Expand Down