This commit is contained in:
2025-12-30 14:14:48 +01:00
parent 32d6da6f0c
commit f4348d0e05

View File

@@ -18,14 +18,14 @@ class MQTTForwarder:
def start(self, src_topic: str, dst_topic: str):
try:
def forward_handler(topic: str, msg: str):
forwarded_msg = self.__wrapData(msg)
forwarded_msg = self.__wrap_data(msg)
self.central_broker.publish(dst_topic, forwarded_msg)
self.local_broker.subscribe(src_topic, forward_handler)
except Exception as e:
print(f"An error occurred while forwarding from {src_topic} to {dst_topic}: {e}")
def __wrapData(self, msg : str):
def __wrap_data(self, msg : str):
result = {}
data = json.loads(msg)
result["timestamp"] = int(time.time())
@@ -33,4 +33,4 @@ class MQTTForwarder:
result["data"] = {}
for keys in data:
result["data"][keys] = data[keys]
return result