added whatsminer get bad boards
This commit is contained in:
@@ -91,7 +91,7 @@ class BTMinerAPI(BaseMinerAPI):
|
|||||||
self.admin_pwd = WHATSMINER_PWD
|
self.admin_pwd = WHATSMINER_PWD
|
||||||
self.current_token = None
|
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."""
|
"""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
|
# check if command is a string, if its bytes its encoded and needs to be send raw
|
||||||
if isinstance(command, str):
|
if isinstance(command, str):
|
||||||
@@ -137,10 +137,11 @@ class BTMinerAPI(BaseMinerAPI):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
# if it fails to validate, it is likely an error
|
if not ignore_errors:
|
||||||
validation = self.validate_command_output(data)
|
# if it fails to validate, it is likely an error
|
||||||
if not validation[0]:
|
validation = self.validate_command_output(data)
|
||||||
raise APIError(validation[1])
|
if not validation[0]:
|
||||||
|
raise APIError(validation[1])
|
||||||
|
|
||||||
# return the parsed json as a dict
|
# return the parsed json as a dict
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ class BOSMiner(BaseMiner):
|
|||||||
devdetails = await self.api.devdetails()
|
devdetails = await self.api.devdetails()
|
||||||
if not devdetails.get("DEVDETAILS"):
|
if not devdetails.get("DEVDETAILS"):
|
||||||
print("devdetails error", devdetails)
|
print("devdetails error", devdetails)
|
||||||
return {6: [], 7: [], 8: []}
|
return {0: [], 1: [], 2: []}
|
||||||
devs = devdetails['DEVDETAILS']
|
devs = devdetails['DEVDETAILS']
|
||||||
boards = {}
|
boards = {}
|
||||||
offset = devs[0]["ID"]
|
offset = devs[0]["ID"]
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ class BTMiner(BaseMiner):
|
|||||||
api = BTMinerAPI(ip)
|
api = BTMinerAPI(ip)
|
||||||
self.model = None
|
self.model = None
|
||||||
super().__init__(ip, api)
|
super().__init__(ip, api)
|
||||||
|
self.nominal_chips = 66
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"BTMiner: {str(self.ip)}"
|
return f"BTMiner: {str(self.ip)}"
|
||||||
@@ -28,3 +29,31 @@ class BTMiner(BaseMiner):
|
|||||||
return host_data["Msg"]["hostname"]
|
return host_data["Msg"]["hostname"]
|
||||||
except APIError:
|
except APIError:
|
||||||
return "?"
|
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:
|
else:
|
||||||
# if all that fails, try just version
|
# if all that fails, try just version
|
||||||
data = await self._send_api_command(str(ip), "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
|
return model
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from miners.btminer import BTMiner
|
|||||||
class BTMinerM21(BTMiner):
|
class BTMinerM21(BTMiner):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
|
self.nominal_chips = [105, 66]
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"M21 - BTMiner: {str(self.ip)}"
|
return f"M21 - BTMiner: {str(self.ip)}"
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ from miners.btminer import BTMiner
|
|||||||
class BTMinerM31(BTMiner):
|
class BTMinerM31(BTMiner):
|
||||||
def __init__(self, ip: str) -> None:
|
def __init__(self, ip: str) -> None:
|
||||||
super().__init__(ip)
|
super().__init__(ip)
|
||||||
|
self.nominal_chips = [78]
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
return f"M31 - BTMiner: {str(self.ip)}"
|
return f"M31 - BTMiner: {str(self.ip)}"
|
||||||
|
|||||||
Reference in New Issue
Block a user