vroy / python-sengled-client

A simple Python client to control Sengled [light] accessories.
MIT License
23 stars 4 forks source link

Add retry clause for login #6

Closed lukejweaver closed 3 years ago

lukejweaver commented 3 years ago

Problem/Proposed fix

I found that, due to Sengled's flaky servers, the login command would often fail with the message: {'ret': -1, 'msg': 'System error', 'gret': 0, 'serverVersionMin': '3', 'serverVersionNow': '3'}

This can be frustrating, especially as it is not a problem with this API itself.

The proposed fix repeats the login request if the relevant flag is present until it either succeeds or surpasses the specific maximum value (we do not want it to get stuck in an infinite loop).