Fixed bug (script not reporting data to influx) when the influxdb server is temporarily down
This commit is contained in:
@@ -130,8 +130,6 @@ if __name__ == "__main__": # if run from cli (not imported as a module)
|
||||
mqtt_client.connect(mq_broker, mq_port, 60)
|
||||
mqtt_client.loop_start()
|
||||
|
||||
influx_client = InfluxDBClient(db_host, db_port, db_user, db_pwd, db_name)
|
||||
|
||||
## define the report functions (to be run in a thread)
|
||||
def threaded_mqtt_report():
|
||||
last_data = data
|
||||
@@ -179,6 +177,7 @@ if __name__ == "__main__": # if run from cli (not imported as a module)
|
||||
}
|
||||
}
|
||||
]
|
||||
influx_client = InfluxDBClient(db_host, db_port, db_user, db_pwd, db_name)
|
||||
influx_client.write_points(json_body)
|
||||
print(f"{bcolors.OKBLUE}Written data to the {bcolors.BOLD}influx database.{bcolors.ENDC}")
|
||||
|
||||
|
Reference in New Issue
Block a user