Refactor Sunnylink registration condition

The condition for Sunnylink registration has been simplified and refactored within the main loop. Previously, the "is_registered" variable was being set outside the registration loop. Now, the checking process of the dongle ID in regard to the registration status is directly integrated into the while condition. This makes the code more concise and the process flow clearer.
This commit is contained in:
DevTekVE
2024-06-19 21:28:31 +02:00
parent 7dc412fcf1
commit 61843ee71c
+1 -2
View File
@@ -190,8 +190,7 @@ def main(exit_event: threading.Event = None):
except Exception:
cloudlog.exception("failed to set core affinity")
is_registered = params.get("SunnylinkDongleId", encoding='utf-8') not in (None, UNREGISTERED_SUNNYLINK_DONGLE_ID)
while params.get_bool("SunnylinkEnabled") and not is_registered:
while params.get_bool("SunnylinkEnabled") and not params.get("SunnylinkDongleId", encoding='utf-8') not in (None, UNREGISTERED_SUNNYLINK_DONGLE_ID):
cloudlog.info("Waiting for sunnylink registration to complete")
time.sleep(10)