Skip to content
Snippets Groups Projects
Commit ac4f8c89 authored by Bert Palm's avatar Bert Palm :bug:
Browse files

fixed missing topic

parent 6c9e0ced
No related branches found
No related tags found
1 merge request!240[cron] inform downstream service about new parsed data
Pipeline #484132 passed
......@@ -109,7 +109,7 @@ def main(thing_uuid, parameters, target_uri):
f"Successfully inserted {len(parsed_observations['observations'])} "
f"observations for thing {thing_uuid} from Bosch API into TimeIO DB"
)
mqtt.send_mqtt_info(json.dumps({"thing": thing_uuid}))
mqtt.send_mqtt_info("data_parsed", json.dumps({"thing": thing_uuid}))
if __name__ == "__main__":
......
......@@ -105,7 +105,7 @@ def main(thing_uuid, parameters, target_uri):
f"Successfully inserted {len(parsed_observations['observations'])} "
f"observations for thing {thing_uuid} from DWD API into TimeIO DB"
)
mqtt.send_mqtt_info(json.dumps({"thing": thing_uuid}))
mqtt.send_mqtt_info("data_parsed", json.dumps({"thing": thing_uuid}))
if __name__ == "__main__":
......
......@@ -6,7 +6,6 @@ import paho.mqtt.publish
try:
_broker = os.environ["MQTT_BROKER"]
mqtt_setting = {
"topic": os.environ["MQTT_TOPIC"],
"qos": int(os.environ["MQTT_QOS"]),
"hostname": _broker.split(":")[0],
"port": int(_broker.split(":")[1]),
......@@ -20,8 +19,8 @@ except KeyError as e:
raise EnvironmentError(f"Missing environment variable {e}")
def send_mqtt_info(payload: str):
def send_mqtt_info(topic, payload: str):
"""
Publish a single mqtt message to a broker, then disconnect cleanly.
"""
paho.mqtt.publish.single(**mqtt_setting, payload=payload)
paho.mqtt.publish.single(**mqtt_setting, topic=topic, payload=payload)
......@@ -126,7 +126,7 @@ def main(thing_uuid: str, parameters: str, target_uri: str):
f"Successfully inserted {len(parsed_observations['observations'])} "
f"observations for thing {thing_uuid} from NM API into TimeIO DB"
)
mqtt.send_mqtt_info(json.dumps({"thing": thing_uuid}))
mqtt.send_mqtt_info("data_parsed", json.dumps({"thing": thing_uuid}))
if __name__ == "__main__":
......
......@@ -74,7 +74,7 @@ def main(thing_uuid: str, parameters: str, target_uri: str):
f"Successfully inserted {len(post_data['observations'])} "
f"observations for thing {thing_uuid} from TTN API into TimeIO DB"
)
mqtt.send_mqtt_info(json.dumps({"thing": thing_uuid}))
mqtt.send_mqtt_info("data_parsed", json.dumps({"thing": thing_uuid}))
if __name__ == "__main__":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment