add fault light command to X19 miners

This commit is contained in:
UpstreamData
2022-05-31 16:54:56 -06:00
parent d36eef4c33
commit 844deec0d3
6 changed files with 150 additions and 0 deletions

View File

@@ -1,6 +1,9 @@
from miners._backends import BMMiner # noqa - Ignore access to _module
from miners._types import S19a # noqa - Ignore access to _module
import httpx
import json
class BMMinerS19a(BMMiner, S19a):
def __init__(self, ip: str) -> None:
@@ -9,3 +12,25 @@ class BMMinerS19a(BMMiner, S19a):
async def get_hostname(self) -> str:
return "?"
async def fault_light_on(self) -> bool:
url = f"http://{self.ip}/cgi-bin/blink.cgi"
auth = httpx.DigestAuth("root", "root")
data = json.dumps({"blink": "true"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B000":
return True
return False
async def fault_light_off(self) -> bool:
url = f"http://{self.ip}/cgi-bin/blink.cgi"
auth = httpx.DigestAuth("root", "root")
data = json.dumps({"blink": "false"})
async with httpx.AsyncClient() as client:
data = await client.post(url, data=data, auth=auth)
data = data.json()
if data.get("code") == "B100":
return True
return False