From a9bb7d2e5a9ea550f7695dd2e0344d2dc964e7ff Mon Sep 17 00:00:00 2001 From: Elias Kunnas Date: Fri, 15 Sep 2023 17:56:29 +0300 Subject: [PATCH] Fix btminer pre_power_on (#62) --- pyasic/API/btminer.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyasic/API/btminer.py b/pyasic/API/btminer.py index 77952a1d..686f9940 100644 --- a/pyasic/API/btminer.py +++ b/pyasic/API/btminer.py @@ -22,7 +22,7 @@ import hashlib import json import logging import re -from typing import Union +from typing import Literal, Union from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from passlib.handlers.md5_crypt import md5_crypt @@ -40,6 +40,12 @@ from pyasic.settings import PyasicSettings # you change the password, you can pass that to this class as pwd, # or add it as the Whatsminer_pwd in the settings.toml file. +PrePowerOnMessage = Union[ + Literal["wait for adjust temp"], + Literal["adjust complete"], + Literal["adjust continue"], +] + def _crypt(word: str, salt: str) -> str: """Encrypts a word with a salt, using a standard salt format. @@ -693,7 +699,7 @@ class BTMinerAPI(BaseMinerAPI): ) return await self.send_privileged_command("set_power_pct", percent=str(percent)) - async def pre_power_on(self, complete: bool, msg: str) -> dict: + async def pre_power_on(self, complete: bool, msg: PrePowerOnMessage) -> dict: """Configure or check status of pre power on.
@@ -713,7 +719,7 @@ class BTMinerAPI(BaseMinerAPI):
""" - if not msg == "wait for adjust temp" or "adjust complete" or "adjust continue": + if msg not in ("wait for adjust temp", "adjust complete", "adjust continue"): raise APIError( "Message is incorrect, please choose one of " '["wait for adjust temp", '