Fix btminer pre_power_on (#62)

This commit is contained in:
Elias Kunnas
2023-09-15 17:56:29 +03:00
committed by GitHub
parent 11295f27a7
commit a9bb7d2e5a

View File

@@ -22,7 +22,7 @@ import hashlib
import json import json
import logging import logging
import re import re
from typing import Union from typing import Literal, Union
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from passlib.handlers.md5_crypt import md5_crypt 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, # 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. # 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: def _crypt(word: str, salt: str) -> str:
"""Encrypts a word with a salt, using a standard salt format. """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)) 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. """Configure or check status of pre power on.
<details> <details>
@@ -713,7 +719,7 @@ class BTMinerAPI(BaseMinerAPI):
</details> </details>
""" """
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( raise APIError(
"Message is incorrect, please choose one of " "Message is incorrect, please choose one of "
'["wait for adjust temp", ' '["wait for adjust temp", '