That's a good idea. I currently have the block I shared above inside of a try/except block, but just for a KeyboardInterrupt (ie, Ctrl+C-ing out of the script when I run it manually).
With my MQTT I find I need to put in try/except to ensure connection/publication.
What I suggest you do is trap to see what the error is causing the problem.
I added this second exception to the script:
Code:
except Exception as e: print("An error occured: {}".format(e)) with open("error_log.txt", "a") as file: file.write("An error occured:\n") file.write(str(e) + "\n") traceback.print_exc(file=file) file.write("-" * 20 + "\n")-Joe
Statistics: Posted by joebro391 — Wed May 07, 2025 9:36 pm