From 95f7146eef173f17904681b4795efded29fde968 Mon Sep 17 00:00:00 2001 From: Upstream Data Date: Sun, 6 Aug 2023 17:23:58 -0600 Subject: [PATCH] feature: add VNish pause/resume commands. --- pyasic/miners/backends/vnish.py | 18 ++++++++++++++++++ pyasic/web/__init__.py | 2 +- pyasic/web/vnish.py | 24 ++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/pyasic/miners/backends/vnish.py b/pyasic/miners/backends/vnish.py index 49376896..b4767ce0 100644 --- a/pyasic/miners/backends/vnish.py +++ b/pyasic/miners/backends/vnish.py @@ -74,6 +74,24 @@ class VNish(BMMiner): pass return False + async def stop_mining(self) -> bool: + data = await self.web.stop_mining() + if data: + try: + return data["success"] + except KeyError: + pass + return False + + async def resume_mining(self) -> bool: + data = await self.web.resume_mining() + if data: + try: + return data["success"] + except KeyError: + pass + return False + async def reboot(self) -> bool: data = await self.web.reboot() if data: diff --git a/pyasic/web/__init__.py b/pyasic/web/__init__.py index dd837695..5627721c 100644 --- a/pyasic/web/__init__.py +++ b/pyasic/web/__init__.py @@ -24,7 +24,7 @@ from pyasic.errors import APIWarning class BaseWebAPI(ABC): def __init__(self, ip: str) -> None: # ip address of the miner - self.ip = ipaddress.ip_address(ip) + self.ip = ip # ipaddress.ip_address(ip) self.username = "root" self.pwd = "root" diff --git a/pyasic/web/vnish.py b/pyasic/web/vnish.py index d8d3a371..fa88983e 100644 --- a/pyasic/web/vnish.py +++ b/pyasic/web/vnish.py @@ -116,8 +116,32 @@ class VNishWebAPI(BaseWebAPI): async def reboot(self) -> dict: return await self.send_command("system/reboot", post=True) + async def pause_mining(self) -> dict: + return await self.send_command("mining/pause", post=True) + + async def resume_mining(self) -> dict: + return await self.send_command("mining/resume", post=True) + + async def stop_mining(self) -> dict: + return await self.send_command("mining/stop", post=True) + + async def start_mining(self) -> dict: + return await self.send_command("mining/start", post=True) + async def info(self): return await self.send_command("info") async def summary(self): return await self.send_command("summary") + + async def chips(self): + return await self.send_command("chips") + + async def layout(self): + return await self.send_command("layout") + + async def status(self): + return await self.send_command("status") + + async def settings(self): + return await self.send_command("settings")