elad-bar / DahuaVTO2MQTT

Listens to events from Dahua VTO unit and publishes them via MQTT Message
103 stars 39 forks source link

Give Useful message on MQTT connection failure #38

Closed Spartan-II-117 closed 3 years ago

Spartan-II-117 commented 3 years ago

Add more information and stop the loop on MQTT connection failure.

elad-bar commented 3 years ago

Hi, thanks for the PR, In the error logging (1-5) there is an issue: Instead of logger, it should be _LOGGER.

In addition, if you don't mind (otherwise I'll do that later), instead of multiple else if, you can create mapping object of reason code to description, If rc is 0, it will go to success code, otherwise it will try to extract the description from the mapping object, If found - will log it, If not, will log a generic message and finalize the loop

Thanks

Spartan-II-117 commented 3 years ago

I don't know how to do that in python, sorry. It does seem like a better implementation

elad-bar commented 3 years ago

Thanks