Skip to content

Commit

Permalink
Update plugin.py
Browse files Browse the repository at this point in the history
Reformatted to pass test
  • Loading branch information
jeloneal authored Jun 23, 2024
1 parent e077b96 commit f418ffd
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/octoprint_psucontrol_meross/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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)

Expand All @@ -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"],
Expand All @@ -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):
Expand All @@ -160,14 +156,14 @@ def on_api_command(self, event, payload):
message = str(err)
else:
message = "Login successful."

out = {
"rv": message,
"error": (not success),
}
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(
Expand Down

0 comments on commit f418ffd

Please sign in to comment.