fixed more bugs with avalonminers, and added temps

This commit is contained in:
UpstreamData
2022-01-08 15:25:43 -07:00
parent d8bccbccaa
commit 44bcc30130
3 changed files with 27 additions and 6 deletions

View File

@@ -224,13 +224,20 @@ async def get_formatted_data(ip: ipaddress.ip_address):
for board in miner_data["devs"][0]['DEVS']: for board in miner_data["devs"][0]['DEVS']:
if board['Chip Temp Avg'] is not None and not board['Chip Temp Avg'] == 0.0: if board['Chip Temp Avg'] is not None and not board['Chip Temp Avg'] == 0.0:
temps = board['Chip Temp Avg'] temps = board['Chip Temp Avg']
if "stats" in miner_data.keys() and not miner_data["stats"][0]['STATS'] == []: if "stats" in miner_data.keys() and not miner_data["stats"][0]['STATS'] == []:
for temp in ["temp2", "temp1", "temp3"]: for temp in ["temp2", "temp1", "temp3"]:
if temp in miner_data["stats"][0]['STATS'][1].keys(): if temp in miner_data["stats"][0]['STATS'][1].keys():
if miner_data["stats"][0]['STATS'][1][temp] is not None and not miner_data["stats"][0]['STATS'][1][ if miner_data["stats"][0]['STATS'][1][temp] is not None and not miner_data["stats"][0]['STATS'][1][
temp] == 0.0: temp] == 0.0:
temps = miner_data["stats"][0]['STATS'][1][temp] temps = miner_data["stats"][0]['STATS'][1][temp]
miner_data["stats"][0]['STATS'][0].keys()
if any("MM ID" in string for string in miner_data["stats"][0]['STATS'][0].keys()):
temp_all = []
for key in [string for string in miner_data["stats"][0]['STATS'][0].keys() if "MM ID" in string]:
for value in [string for string in miner_data["stats"][0]['STATS'][0][key].split(" ") if
"TMax" in string]:
temp_all.append(int(value.split("[")[1].replace("]", "")))
temps = round(sum(temp_all) / len(temp_all))
if "pools" not in miner_data.keys(): if "pools" not in miner_data.keys():
user = "?" user = "?"

View File

@@ -0,0 +1,11 @@
from miners.cgminer import CGMiner
class CGMinerAvalon(CGMiner):
def __init__(self, ip: str) -> None:
super().__init__(ip)
self.model = "Avalon"
self.api_type = "CGMiner"
def __repr__(self) -> str:
return f"CGMinerAvalon: {str(self.ip)}"

View File

@@ -2,7 +2,6 @@ from miners.antminer.S9.bosminer import BOSMinerS9
from miners.antminer.S9.bmminer import BMMinerS9 from miners.antminer.S9.bmminer import BMMinerS9
from miners.antminer.S9.cgminer import CGMinerS9 from miners.antminer.S9.cgminer import CGMinerS9
from miners.antminer.X17.bosminer import BOSMinerX17 from miners.antminer.X17.bosminer import BOSMinerX17
from miners.antminer.X17.bmminer import BMMinerX17 from miners.antminer.X17.bmminer import BMMinerX17
from miners.antminer.X17.cgminer import CGMinerX17 from miners.antminer.X17.cgminer import CGMinerX17
@@ -16,10 +15,9 @@ from miners.whatsminer.M30 import BTMinerM30
from miners.whatsminer.M31 import BTMinerM31 from miners.whatsminer.M31 import BTMinerM31
from miners.whatsminer.M32 import BTMinerM32 from miners.whatsminer.M32 import BTMinerM32
from miners.bmminer import BMMiner from miners.avalonminer import CGMinerAvalon
from miners.cgminer import CGMiner
from miners.unknown import UnknownMiner from miners.unknown import UnknownMiner
from API import APIError
import asyncio import asyncio
import ipaddress import ipaddress
import json import json
@@ -85,6 +83,8 @@ class MinerFactory:
miner = CGMinerX19(str(ip)) miner = CGMinerX19(str(ip))
elif "BMMiner" in api: elif "BMMiner" in api:
miner = BMMinerX19(str(ip)) miner = BMMinerX19(str(ip))
elif "avalon" in model:
miner = CGMinerAvalon(str(ip))
elif "M20" in model: elif "M20" in model:
miner = BTMinerM20(str(ip)) miner = BTMinerM20(str(ip))
elif "M21" in model: elif "M21" in model:
@@ -116,7 +116,10 @@ class MinerFactory:
except: except:
print(f"Get Model Exception: {ip}") print(f"Get Model Exception: {ip}")
else: else:
if not data["DEVDETAILS"][0]["Model"] == "":
model = data["DEVDETAILS"][0]["Model"] model = data["DEVDETAILS"][0]["Model"]
else:
model = data["DEVDETAILS"][0]["Driver"]
else: else:
try: try:
data = await self._send_api_command(str(ip), "version") data = await self._send_api_command(str(ip), "version")