Skip to content

Commit

Permalink
fix: derive service topic from topic_id
Browse files Browse the repository at this point in the history
  • Loading branch information
reubenmiller committed Sep 24, 2024
1 parent 5169f51 commit 742fe2c
Showing 1 changed file with 4 additions and 3 deletions.
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

0 comments on commit 742fe2c

Please sign in to comment.