Fix reauthentication bug and support authentication intervals
Recursion was used for implementing retry after failed operation. However, after the error_report flag was raised, authentication always returned None. Changed retry logic to iterative implementation to fix the bug and for easier reading of the code. Also removed error_report flag, which seemed to be designed to reduce log pollution during the recursive retries. Added auth_interval parameter for supporting persistent authentication, with reauthentication after given number of seconds (default 10). For some reason the "non-legacy" implementation was to reauthenticate every time (two calls to authenticated + one call for the operation). I had no trouble with my W215 socket without authenticating every time, but maybe there's some device which requires it? auth_interval can be set to zero to force reauthentication every time, but this changes the default operation. Added some debug logging. Bump version number to 0.7.1
@vilsufi, thanks for your PR and I am really sorry for not getting back to you sooner. I never got notifications from GH about the PR. Likely because you didn't add me as a reviewer :thinking: You should just have pinged me when I didn't respond.
I will take a look and get back to you soon. Hopefully within a week. I don't really use the plug myself anymore so it just takes a bit of time to ensure everything still works.
I am very sorry for taking so long to get on with this - I really appriciate the contribution
To anyone reading this in the future - I don't have access to my plugs anymore so I cannot ensure this PR will not break support for older plugs. If someone is able to pull this branch and test the changes I would be happy to merge this. Just ping me in the PR with the steps you have performed, the tested hardware version(s) and your results.