From f418ffd1127952a77dcdddd17931ebaaa3320987 Mon Sep 17 00:00:00 2001 From: jeloneal <48490942+jeloneal@users.noreply.github.com> Date: Sun, 23 Jun 2024 10:14:11 +0200 Subject: [PATCH] Update plugin.py Reformatted to pass test --- src/octoprint_psucontrol_meross/plugin.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/octoprint_psucontrol_meross/plugin.py b/src/octoprint_psucontrol_meross/plugin.py index 837113c..8107686 100644 --- a/src/octoprint_psucontrol_meross/plugin.py +++ b/src/octoprint_psucontrol_meross/plugin.py @@ -85,6 +85,7 @@ def on_settings_migrate(self, target, current): ): if (migrate_from, migrate_to) == (1, 2): # Migrate from settings v1 to v2 + old_dev_id = self._settings.get(["target_device_id"]) if old_dev_id is not None: self._settings.set(["target_device_ids"], [old_dev_id]) @@ -108,7 +109,6 @@ def on_startup(self, host, port): "does not support plugin registration." ) return - self._logger.debug("Registering plugin with PSUControl") psucontrol_helpers["register_plugin"](self) @@ -128,6 +128,7 @@ def get_psu_state(self): return self.meross.is_on(self.target_device_ids) # Setting the location of the assets such as javascript + def get_assets(self): return { "js": ["js/octoprint_psucontrol_settings.js"], @@ -137,12 +138,7 @@ def get_api_commands(self): return { "try_login": ("api_base_url", "user_email", "user_password"), "list_devices": ("api_base_url", "user_email", "user_password"), - "toggle_device": ( - "api_base_url", - "user_email", - "user_password", - "dev_ids" - ), + "toggle_device": ("api_base_url", "user_email", "user_password", "dev_ids"), } def on_api_command(self, event, payload): @@ -160,7 +156,6 @@ def on_api_command(self, event, payload): message = str(err) else: message = "Login successful." - out = { "rv": message, "error": (not success), @@ -168,6 +163,7 @@ def on_api_command(self, event, payload): elif event == "toggle_device": self._logger.debug(f"ON_EVENT {event!r}") # Ensure that we are logged in with the desired credentials + err = False try: self._ensure_meross_login(