made slight optimizations to get_data and the way the miner gets mac data
This commit is contained in:
@@ -80,6 +80,14 @@ class BTMiner(BaseMiner):
|
|||||||
|
|
||||||
async def get_mac(self):
|
async def get_mac(self):
|
||||||
mac = ""
|
mac = ""
|
||||||
|
data = await self.api.summary()
|
||||||
|
if data:
|
||||||
|
if data.get("SUMMARY"):
|
||||||
|
if len(data["SUMMARY"]) > 0:
|
||||||
|
_mac = data["SUMMARY"][0].get("MAC")
|
||||||
|
if _mac:
|
||||||
|
mac = _mac
|
||||||
|
if mac == "":
|
||||||
try:
|
try:
|
||||||
data = await self.api.get_miner_info()
|
data = await self.api.get_miner_info()
|
||||||
if data:
|
if data:
|
||||||
@@ -88,19 +96,14 @@ class BTMiner(BaseMiner):
|
|||||||
mac = data["Msg"]["mac"]
|
mac = data["Msg"]["mac"]
|
||||||
except APIError:
|
except APIError:
|
||||||
pass
|
pass
|
||||||
if mac == "":
|
|
||||||
data = await self.api.summary()
|
|
||||||
if data:
|
|
||||||
if data.get("SUMMARY"):
|
|
||||||
if len(data["SUMMARY"]) > 0:
|
|
||||||
_mac = data["SUMMARY"][0].get("MAC")
|
|
||||||
if _mac:
|
|
||||||
mac = _mac
|
|
||||||
return str(mac).upper()
|
return str(mac).upper()
|
||||||
|
|
||||||
async def get_data(self):
|
async def get_data(self):
|
||||||
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3)
|
data = MinerData(ip=str(self.ip), ideal_chips=self.nominal_chips * 3)
|
||||||
|
|
||||||
|
mac = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
model = await self.get_model()
|
model = await self.get_model()
|
||||||
except APIError:
|
except APIError:
|
||||||
@@ -115,21 +118,12 @@ class BTMiner(BaseMiner):
|
|||||||
hostname = None
|
hostname = None
|
||||||
data.hostname = "Whatsminer"
|
data.hostname = "Whatsminer"
|
||||||
|
|
||||||
try:
|
|
||||||
mac = await self.get_mac()
|
|
||||||
except APIError:
|
|
||||||
logging.info(f"Failed to get mac: {self}")
|
|
||||||
mac = None
|
|
||||||
|
|
||||||
if model:
|
if model:
|
||||||
data.model = model
|
data.model = model
|
||||||
|
|
||||||
if hostname:
|
if hostname:
|
||||||
data.hostname = hostname
|
data.hostname = hostname
|
||||||
|
|
||||||
if mac:
|
|
||||||
data.mac = mac
|
|
||||||
|
|
||||||
miner_data = None
|
miner_data = None
|
||||||
for i in range(DATA_RETRIES):
|
for i in range(DATA_RETRIES):
|
||||||
try:
|
try:
|
||||||
@@ -150,6 +144,9 @@ class BTMiner(BaseMiner):
|
|||||||
summary_data = summary.get("SUMMARY")
|
summary_data = summary.get("SUMMARY")
|
||||||
if summary_data:
|
if summary_data:
|
||||||
if len(summary_data) > 0:
|
if len(summary_data) > 0:
|
||||||
|
if summary_data[0].get("MAC"):
|
||||||
|
mac = summary_data[0]["MAC"]
|
||||||
|
|
||||||
data.fan_1 = summary_data[0]["Fan Speed In"]
|
data.fan_1 = summary_data[0]["Fan Speed In"]
|
||||||
data.fan_2 = summary_data[0]["Fan Speed Out"]
|
data.fan_2 = summary_data[0]["Fan Speed Out"]
|
||||||
|
|
||||||
@@ -233,4 +230,14 @@ class BTMiner(BaseMiner):
|
|||||||
if quota:
|
if quota:
|
||||||
data.pool_split = str(quota)
|
data.pool_split = str(quota)
|
||||||
|
|
||||||
|
if not mac:
|
||||||
|
try:
|
||||||
|
mac = await self.get_mac()
|
||||||
|
except APIError:
|
||||||
|
logging.info(f"Failed to get mac: {self}")
|
||||||
|
mac = None
|
||||||
|
|
||||||
|
if mac:
|
||||||
|
data.mac = mac
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|||||||
Reference in New Issue
Block a user