diff --git a/pyasic/API/__init__.py b/pyasic/API/__init__.py index 77ae8456..502b7ddf 100644 --- a/pyasic/API/__init__.py +++ b/pyasic/API/__init__.py @@ -263,6 +263,12 @@ If you are sure you want to use this command please use API.send_command("{comma else: return False, data["STATUS"][0]["Msg"] + elif isinstance(data["STATUS"], dict): + # new style X19 command + if data["STATUS"]["STATUS"] not in ["S", "I"]: + return False, data["STATUS"]["Msg"] + return True, None + if data["STATUS"] not in ["S", "I"]: return False, data["Msg"] else: diff --git a/pyasic/data/__init__.py b/pyasic/data/__init__.py index b3d02cf3..e894d697 100644 --- a/pyasic/data/__init__.py +++ b/pyasic/data/__init__.py @@ -48,6 +48,7 @@ class HashBoard: chip_temp: int = None chips: int = None expected_chips: int = None + serial_number: str = None missing: bool = True def get(self, __key: str, default: Any = None): diff --git a/pyasic/miners/backends/antminer.py b/pyasic/miners/backends/antminer.py index e4db9916..e314f761 100644 --- a/pyasic/miners/backends/antminer.py +++ b/pyasic/miners/backends/antminer.py @@ -52,9 +52,7 @@ ANTMINER_MODERN_DATA_LOC = DataLocations( str(DataOptions.EXPECTED_HASHRATE): DataFunction( "get_expected_hashrate", [RPCAPICommand("api_stats", "stats")] ), - str(DataOptions.HASHBOARDS): DataFunction( - "get_hashboards", [RPCAPICommand("api_stats", "stats")] - ), + str(DataOptions.HASHBOARDS): DataFunction("get_hashboards", []), str(DataOptions.ENVIRONMENT_TEMP): DataFunction("get_env_temp"), str(DataOptions.WATTAGE): DataFunction("get_wattage"), str(DataOptions.WATTAGE_LIMIT): DataFunction("get_wattage_limit"), @@ -196,6 +194,42 @@ class AntminerModern(BMMiner): pass return errors + async def get_hashboards(self) -> List[HashBoard]: + hashboards = [ + HashBoard(idx, expected_chips=self.expected_chips) + for idx in range(self.expected_hashboards) + ] + + try: + api_stats = await self.api.send_command("stats", new_api=True) + except APIError: + return hashboards + + if api_stats: + try: + for board in api_stats["STATS"][0]["chain"]: + hashboards[board["index"]].hashrate = round( + board["rate_real"] / 1000, 2 + ) + hashboards[board["index"]].chips = board["asic_num"] + board_temp_data = list( + filter(lambda x: not x == 0, board["temp_pcb"]) + ) + hashboards[board["index"]].temp = sum(board_temp_data) / len( + board_temp_data + ) + chip_temp_data = list( + filter(lambda x: not x == 0, board["temp_chip"]) + ) + hashboards[board["index"]].chip_temp = sum(chip_temp_data) / len( + chip_temp_data + ) + hashboards[board["index"]].serial_number = board["sn"] + hashboards[board["index"]].missing = False + except LookupError: + pass + return hashboards + async def get_fault_light(self, web_get_blink_status: dict = None) -> bool: if self.light: return self.light