Closed stegmannb closed 4 years ago
Thank you for the PR!
error
but then I saw the subsequent commit.sys.exit()
which bypasses the cleanup method. I don't see this being a problem right now because everything the cleanup does is predicated on being connected to the broker already anyhow. And I don't foresee the need to ever open resources ahead of trying to connect to the broker.I'll go ahead and merge this. Thanks again for the contribution!
This PR tries to fix #4 and adds on_connect callback. If the connection could not be established an error message is logged.
It also fixes a problem I encountered with HomeAssistant autodiscovery where the config topic gets lost, because it is published before the connection is established. This may be because I use authentication or the broker is running on a slow system.
This is the first I am trying to contribute to an open source project and there may very well be a more elegant solution, so any feedback is appreciated.