fix some bugs and start adding bmminer get_data function

This commit is contained in:
UpstreamData
2022-05-05 10:52:18 -06:00
parent e6ea8d3e16
commit a13f5dd2d1
3 changed files with 31 additions and 7 deletions

View File

@@ -214,13 +214,11 @@ class MinerFactory:
version = data["version"][0]
except APIError as e:
logging.warning(f"{ip}: API Command Error: {e}")
data = None
if not data:
try:
devdetails = await self._send_api_command(str(ip), "devdetails")
validation = await self._validate_command(devdetails)
if not validation[0]:
version = await self._send_api_command(str(ip), "version")
@@ -260,11 +258,14 @@ class MinerFactory:
# if all that fails, check the Description to see if it is a whatsminer
elif version.get("Description") and "whatsminer" in version.get("Description"):
api = "BTMiner"
if version and not model:
if "VERSION" in version.keys() and not version["DEVDETAILS"] == []:
if (
"VERSION" in version.keys()
and version.get("VERSION")
and not version.get("VERSION") == []
):
model = version["VERSION"][0]["Type"]
print("done")
return model, api
async def _validate_command(self, data: dict) -> tuple: