bug: fix some of the issues with bitaxe.

This commit is contained in:
upstreamdata
2024-06-28 22:43:13 -06:00
parent 923e963369
commit fca72eb747
6 changed files with 67 additions and 16 deletions

View File

@@ -1,3 +1,5 @@
from __future__ import annotations
from dataclasses import dataclass, field
from pyasic.config.base import MinerConfigOption, MinerConfigValue

View File

@@ -10,23 +10,31 @@ BITAXE_DATA_LOC = DataLocations(
**{
str(DataOptions.HASHRATE): DataFunction(
"_get_hashrate",
[WebAPICommand("web_system_info", "system_info")],
[WebAPICommand("web_system_info", "system/info")],
),
str(DataOptions.WATTAGE): DataFunction(
"_get_wattage",
[WebAPICommand("web_system_info", "system_info")],
[WebAPICommand("web_system_info", "system/info")],
),
str(DataOptions.UPTIME): DataFunction(
"_get_uptime",
[WebAPICommand("web_system_info", "system_info")],
[WebAPICommand("web_system_info", "system/info")],
),
str(DataOptions.HASHBOARDS): DataFunction(
"_get_hashboards",
[WebAPICommand("web_system_info", "system_info")],
[WebAPICommand("web_system_info", "system/info")],
),
str(DataOptions.FANS): DataFunction(
"_get_fans",
[WebAPICommand("web_system_info", "system_info")],
[WebAPICommand("web_system_info", "system/info")],
),
str(DataOptions.FW_VERSION): DataFunction(
"_get_fw_ver",
[WebAPICommand("web_system_info", "system/info")],
),
str(DataOptions.API_VERSION): DataFunction(
"_get_api_ver",
[WebAPICommand("web_system_info", "system/info")],
),
}
)
@@ -50,10 +58,9 @@ class BitAxe(BaseMiner):
web_system_info = await self.web.system_info()
except APIError:
pass
if web_system_info is not None:
try:
return web_system_info["power"]
return round(web_system_info["power"])
except KeyError:
pass
@@ -101,13 +108,13 @@ class BitAxe(BaseMiner):
hashrate=AlgoHashRate.SHA256(
web_system_info["hashRate"], HashUnit.SHA256.GH
).into(self.algo.unit.default),
chip_temp=web_system_info["temp"],
temp=web_system_info["vrTemp"],
chips=web_system_info["asicCount"],
chip_temp=web_system_info.get("temp"),
temp=web_system_info.get("vrTemp"),
chips=web_system_info.get("asicCount"),
expected_chips=self.expected_chips,
missing=False,
active=True,
voltage=web_system_info["voltage"],
voltage=web_system_info.get("voltage"),
)
]
except KeyError:
@@ -127,3 +134,42 @@ class BitAxe(BaseMiner):
except KeyError:
pass
return []
async def _get_hostname(self, web_system_info: dict = None) -> Optional[str]:
if web_system_info is None:
try:
web_system_info = await self.web.system_info()
except APIError:
pass
if web_system_info is not None:
try:
return web_system_info["hostname"]
except KeyError:
pass
async def _get_api_ver(self, web_system_info: dict = None) -> Optional[str]:
if web_system_info is None:
try:
web_system_info = await self.web.system_info()
except APIError:
pass
if web_system_info is not None:
try:
return web_system_info["version"]
except KeyError:
pass
async def _get_fw_ver(self, web_system_info: dict = None) -> Optional[str]:
if web_system_info is None:
try:
web_system_info = await self.web.system_info()
except APIError:
pass
if web_system_info is not None:
try:
return web_system_info["version"]
except KeyError:
pass

View File

@@ -5,5 +5,6 @@ from pyasic.miners.device.makes import BitAxeMake
class Ultra(BitAxeMake):
raw_model = MinerModel.BITAXE.BM1366
expected_hashboards = 1
expected_chips = 1
expected_fans = 1

View File

@@ -5,5 +5,6 @@ from pyasic.miners.device.makes import BitAxeMake
class Supra(BitAxeMake):
raw_model = MinerModel.BITAXE.BM1368
expected_hashboards = 1
expected_chips = 1
expected_fans = 1

View File

@@ -5,5 +5,6 @@ from pyasic.miners.device.makes import BitAxeMake
class Max(BitAxeMake):
raw_model = MinerModel.BITAXE.BM1397
expected_hashboards = 1
expected_chips = 1
expected_fans = 1

View File

@@ -19,7 +19,7 @@ class BitAxeWebAPI(BaseWebAPI):
privileged: bool = False,
**parameters: Any,
) -> dict:
url = f"http://{self.ip}:{self.port}/{command}"
url = f"http://{self.ip}:{self.port}/api/{command}"
try:
async with httpx.AsyncClient(
transport=settings.transport(),
@@ -44,7 +44,7 @@ class BitAxeWebAPI(BaseWebAPI):
async def multicommand(
self, *commands: str, ignore_errors: bool = False, allow_warning: bool = True
) -> dict:
"""Execute multiple commands simultaneously on the Auradine miner.
"""Execute multiple commands simultaneously on the BitAxe miner.
Args:
*commands (str): Commands to execute.
@@ -76,10 +76,10 @@ class BitAxeWebAPI(BaseWebAPI):
return data
async def system_info(self):
return await self.send_command("api/system/info")
return await self.send_command("system/info")
async def swarm_info(self):
return await self.send_command("api/swarm/info")
return await self.send_command("swarm/info")
async def restart(self):
return await self.send_command("api/system/restart", post=True)
return await self.send_command("system/restart", post=True)