added whatsminer get bad boards
This commit is contained in:
@@ -91,7 +91,7 @@ class BTMinerAPI(BaseMinerAPI):
|
||||
self.admin_pwd = WHATSMINER_PWD
|
||||
self.current_token = None
|
||||
|
||||
async def send_command(self, command: str | bytes, **kwargs) -> dict:
|
||||
async def send_command(self, command: str | bytes, ignore_errors: bool = False, **kwargs) -> dict:
|
||||
"""Send an API command to the miner and return the result."""
|
||||
# check if command is a string, if its bytes its encoded and needs to be send raw
|
||||
if isinstance(command, str):
|
||||
@@ -137,10 +137,11 @@ class BTMinerAPI(BaseMinerAPI):
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
# if it fails to validate, it is likely an error
|
||||
validation = self.validate_command_output(data)
|
||||
if not validation[0]:
|
||||
raise APIError(validation[1])
|
||||
if not ignore_errors:
|
||||
# if it fails to validate, it is likely an error
|
||||
validation = self.validate_command_output(data)
|
||||
if not validation[0]:
|
||||
raise APIError(validation[1])
|
||||
|
||||
# return the parsed json as a dict
|
||||
return data
|
||||
|
||||
@@ -115,7 +115,7 @@ class BOSMiner(BaseMiner):
|
||||
devdetails = await self.api.devdetails()
|
||||
if not devdetails.get("DEVDETAILS"):
|
||||
print("devdetails error", devdetails)
|
||||
return {6: [], 7: [], 8: []}
|
||||
return {0: [], 1: [], 2: []}
|
||||
devs = devdetails['DEVDETAILS']
|
||||
boards = {}
|
||||
offset = devs[0]["ID"]
|
||||
|
||||
@@ -8,6 +8,7 @@ class BTMiner(BaseMiner):
|
||||
api = BTMinerAPI(ip)
|
||||
self.model = None
|
||||
super().__init__(ip, api)
|
||||
self.nominal_chips = 66
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"BTMiner: {str(self.ip)}"
|
||||
@@ -28,3 +29,31 @@ class BTMiner(BaseMiner):
|
||||
return host_data["Msg"]["hostname"]
|
||||
except APIError:
|
||||
return "?"
|
||||
|
||||
|
||||
async def get_board_info(self) -> dict:
|
||||
"""Gets data on each board and chain in the miner."""
|
||||
devs = await self.api.devs()
|
||||
if not devs.get("DEVS"):
|
||||
print("devs error", devs)
|
||||
return {0: [], 1: [], 2: []}
|
||||
devs = devs["DEVS"]
|
||||
boards = {}
|
||||
offset = devs[0]["ID"]
|
||||
for board in devs:
|
||||
boards[board["ID"] - offset] = []
|
||||
if "Effective Chips" in board.keys():
|
||||
if not board['Effective Chips'] in self.nominal_chips:
|
||||
nominal = False
|
||||
else:
|
||||
nominal = True
|
||||
boards[board["ID"] - offset].append({
|
||||
"chain": board["ID"] - offset,
|
||||
"chip_count": board['Effective Chips'],
|
||||
"chip_status": "o" * board['Effective Chips'],
|
||||
"nominal": nominal
|
||||
})
|
||||
else:
|
||||
print(board)
|
||||
return boards
|
||||
|
||||
|
||||
@@ -219,7 +219,10 @@ class MinerFactory:
|
||||
else:
|
||||
# if all that fails, try just version
|
||||
data = await self._send_api_command(str(ip), "version")
|
||||
model = data["VERSION"][0]["Type"]
|
||||
if "VERSION" in data.keys():
|
||||
model = data["VERSION"][0]["Type"]
|
||||
else:
|
||||
print(data)
|
||||
|
||||
return model
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from miners.btminer import BTMiner
|
||||
class BTMinerM21(BTMiner):
|
||||
def __init__(self, ip: str) -> None:
|
||||
super().__init__(ip)
|
||||
self.nominal_chips = [105, 66]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"M21 - BTMiner: {str(self.ip)}"
|
||||
|
||||
@@ -4,6 +4,7 @@ from miners.btminer import BTMiner
|
||||
class BTMinerM31(BTMiner):
|
||||
def __init__(self, ip: str) -> None:
|
||||
super().__init__(ip)
|
||||
self.nominal_chips = [78]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"M31 - BTMiner: {str(self.ip)}"
|
||||
|
||||
Reference in New Issue
Block a user