Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

Commit bd580be

Browse files
committed
bug: fix more identification issues and issues with 3.14
1 parent 7d7a08c commit bd580be

3 files changed

Lines changed: 28 additions & 9 deletions

File tree

pyasic/data/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def hashrate(self) -> AlgoHashRateType | None:
215215
return sum(
216216
hr_data,
217217
start=self.device_info.algo.hashrate(
218-
rate=0, unit=GenericUnit.H
218+
rate=0, unit=self.device_info.algo.unit.default
219219
),
220220
)
221221
else:

pyasic/miners/backends/btminer.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from pyasic.data import Fan, HashBoard
2525
from pyasic.data.error_codes import MinerErrorData, WhatsminerError
2626
from pyasic.data.pools import PoolMetrics, PoolUrl
27+
from pyasic.device import MinerAlgo
2728
from pyasic.device.algorithm import AlgoHashRateType
2829
from pyasic.errors import APIError
2930
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
@@ -1163,7 +1164,11 @@ async def _get_hashboards(
11631164
board_count = (
11641165
rpc_get_device_info.get("msg", {}).get("hardware", {}).get("boards", 3)
11651166
)
1166-
edevs = rpc_get_miner_status_edevs.get("msg", {}).get("edevs", [])
1167+
edevs_base = rpc_get_miner_status_edevs.get("msg", {})
1168+
if isinstance(edevs_base, dict):
1169+
edevs = edevs_base.get("edevs", [])
1170+
else:
1171+
edevs = []
11671172
for idx in range(board_count):
11681173
board_data = edevs[idx] if idx < len(edevs) else {}
11691174
boards.append(
@@ -1262,12 +1267,19 @@ async def _get_hashrate(
12621267
if rpc_get_miner_status_summary is None:
12631268
return None
12641269

1265-
return (
1270+
res = (
12661271
rpc_get_miner_status_summary.get("msg", {})
12671272
.get("summary", {})
12681273
.get("hash-realtime")
12691274
)
12701275

1276+
if res is not None:
1277+
return self.algo.hashrate(
1278+
rate=float(res),
1279+
unit=self.algo.unit.TH, # type: ignore[attr-defined]
1280+
).into(self.algo.unit.default) # type: ignore[attr-defined]
1281+
return None
1282+
12711283
async def _get_expected_hashrate(
12721284
self, rpc_get_miner_status_summary: dict | None = None
12731285
) -> AlgoHashRateType | None:
@@ -1288,7 +1300,13 @@ async def _get_expected_hashrate(
12881300
-0.001 * self.expected_hashboards
12891301
):
12901302
return None
1291-
return res
1303+
1304+
if res is not None:
1305+
return self.algo.hashrate(
1306+
rate=float(res),
1307+
unit=self.algo.unit.TH, # type: ignore[attr-defined]
1308+
).into(self.algo.unit.default) # type: ignore[attr-defined]
1309+
return None
12921310

12931311
async def _get_env_temp(
12941312
self, rpc_get_miner_status_summary: dict | None = None

pyasic/miners/factory.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ async def _socket_ping(ip: str, cmd: str) -> str | None:
994994
try:
995995
await writer.wait_closed()
996996
except (ConnectionError, OSError):
997-
return None
997+
pass
998998
if data:
999999
return data.decode("utf-8")
10001000
return None
@@ -1272,10 +1272,11 @@ async def get_miner_model_whatsminer(self, ip: str) -> str | None:
12721272
return miner_model
12731273
except (TypeError, LookupError):
12741274
pass
1275-
else:
1276-
sock_json_data_v3 = await self.send_btminer_v3_api_command(
1277-
ip, "get.device.info"
1278-
)
1275+
1276+
sock_json_data_v3 = await self.send_btminer_v3_api_command(
1277+
ip, "get.device.info"
1278+
)
1279+
if sock_json_data_v3 is not None:
12791280
try:
12801281
miner_model = sock_json_data_v3["msg"]["miner"]["type"].replace("_", "")
12811282
miner_model = miner_model[:-1] + "0"

0 commit comments

Comments
 (0)