Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a5d793cd6 | ||
|
|
1894ff1aea | ||
|
|
3ab9294000 | ||
|
|
5e0641634b | ||
|
|
a1975bc9b8 | ||
|
|
6a265f03f7 | ||
|
|
c3658f028f | ||
|
|
ba3c653a29 | ||
|
|
61fbc132ed | ||
|
|
3f9f232990 | ||
|
|
29c2398846 | ||
|
|
ecc161820d | ||
|
|
5fec3052f6 | ||
|
|
437ee774ab | ||
|
|
aed9e0e406 | ||
|
|
be96428823 | ||
|
|
446881b237 | ||
|
|
ceab8e55b5 | ||
|
|
e12f85c94d | ||
|
|
0c85f53177 |
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
|
|
||||||
from pyasic.config.fans import FanMode, FanModeConfig
|
from pyasic.config.fans import FanMode, FanModeConfig, FanModeNormal
|
||||||
from pyasic.config.mining import MiningMode, MiningModeConfig
|
from pyasic.config.mining import MiningMode, MiningModeConfig
|
||||||
from pyasic.config.mining.scaling import ScalingConfig
|
from pyasic.config.mining.scaling import ScalingConfig
|
||||||
from pyasic.config.pools import PoolConfig
|
from pyasic.config.pools import PoolConfig
|
||||||
@@ -159,6 +159,19 @@ class MinerConfig(BaseModel):
|
|||||||
**self.pools.as_luxos(user_suffix=user_suffix),
|
**self.pools.as_luxos(user_suffix=user_suffix),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def as_vnish(self, user_suffix: str = None) -> dict:
|
||||||
|
main_cfg = {
|
||||||
|
"miner": {
|
||||||
|
**self.fan_mode.as_vnish(),
|
||||||
|
**self.temperature.as_vnish(),
|
||||||
|
**self.mining_mode.as_vnish(),
|
||||||
|
**self.pools.as_vnish(user_suffix=user_suffix),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if isinstance(self.fan_mode, FanModeNormal):
|
||||||
|
main_cfg["miner"]["cooling"]["mode"]["param"] = self.temperature.target
|
||||||
|
return main_cfg
|
||||||
|
|
||||||
def as_hammer(self, *args, **kwargs) -> dict:
|
def as_hammer(self, *args, **kwargs) -> dict:
|
||||||
return self.as_am_modern(*args, **kwargs)
|
return self.as_am_modern(*args, **kwargs)
|
||||||
|
|
||||||
|
|||||||
@@ -87,6 +87,18 @@ class FanModeNormal(MinerConfigValue):
|
|||||||
def as_luxos(self) -> dict:
|
def as_luxos(self) -> dict:
|
||||||
return {"fanset": {"speed": -1, "min_fans": self.minimum_fans}}
|
return {"fanset": {"speed": -1, "min_fans": self.minimum_fans}}
|
||||||
|
|
||||||
|
def as_vnish(self) -> dict:
|
||||||
|
return {
|
||||||
|
"cooling": {
|
||||||
|
"fan_min_count": self.minimum_fans,
|
||||||
|
"fan_min_duty": self.minimum_speed,
|
||||||
|
"mode": {
|
||||||
|
"name": "auto",
|
||||||
|
"param": None, # Target temp, must be set later...
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class FanModeManual(MinerConfigValue):
|
class FanModeManual(MinerConfigValue):
|
||||||
mode: str = Field(init=False, default="manual")
|
mode: str = Field(init=False, default="manual")
|
||||||
@@ -150,6 +162,18 @@ class FanModeManual(MinerConfigValue):
|
|||||||
def as_luxos(self) -> dict:
|
def as_luxos(self) -> dict:
|
||||||
return {"fanset": {"speed": self.speed, "min_fans": self.minimum_fans}}
|
return {"fanset": {"speed": self.speed, "min_fans": self.minimum_fans}}
|
||||||
|
|
||||||
|
def as_vnish(self) -> dict:
|
||||||
|
return {
|
||||||
|
"cooling": {
|
||||||
|
"fan_min_count": self.minimum_fans,
|
||||||
|
"fan_min_duty": self.speed,
|
||||||
|
"mode": {
|
||||||
|
"name": "manual",
|
||||||
|
"param": self.speed, # Speed value
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class FanModeImmersion(MinerConfigValue):
|
class FanModeImmersion(MinerConfigValue):
|
||||||
mode: str = Field(init=False, default="immersion")
|
mode: str = Field(init=False, default="immersion")
|
||||||
@@ -175,6 +199,9 @@ class FanModeImmersion(MinerConfigValue):
|
|||||||
def as_luxos(self) -> dict:
|
def as_luxos(self) -> dict:
|
||||||
return {"fanset": {"speed": 0, "min_fans": 0}}
|
return {"fanset": {"speed": 0, "min_fans": 0}}
|
||||||
|
|
||||||
|
def as_vnish(self) -> dict:
|
||||||
|
return {"cooling": {"mode": {"name": "immers"}}}
|
||||||
|
|
||||||
|
|
||||||
class FanModeConfig(MinerConfigOption):
|
class FanModeConfig(MinerConfigOption):
|
||||||
normal = FanModeNormal
|
normal = FanModeNormal
|
||||||
|
|||||||
@@ -357,6 +357,9 @@ class ManualBoardSettings(MinerConfigValue):
|
|||||||
return {"miner-mode": "0"}
|
return {"miner-mode": "0"}
|
||||||
return {"miner-mode": 0}
|
return {"miner-mode": 0}
|
||||||
|
|
||||||
|
def as_vnish(self) -> dict:
|
||||||
|
return {"freq": self.freq}
|
||||||
|
|
||||||
|
|
||||||
class MiningModeManual(MinerConfigValue):
|
class MiningModeManual(MinerConfigValue):
|
||||||
mode: str = field(init=False, default="manual")
|
mode: str = field(init=False, default="manual")
|
||||||
@@ -378,6 +381,18 @@ class MiningModeManual(MinerConfigValue):
|
|||||||
return {"miner-mode": "0"}
|
return {"miner-mode": "0"}
|
||||||
return {"miner-mode": 0}
|
return {"miner-mode": 0}
|
||||||
|
|
||||||
|
def as_vnish(self) -> dict:
|
||||||
|
chains = [b.as_vnish() for b in self.boards.values() if b.freq != 0]
|
||||||
|
return {
|
||||||
|
"overclock": {
|
||||||
|
"chains": chains if chains != [] else None,
|
||||||
|
"globals": {
|
||||||
|
"freq": int(self.global_freq),
|
||||||
|
"volt": int(self.global_volt),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_vnish(cls, web_overclock_settings: dict) -> "MiningModeManual":
|
def from_vnish(cls, web_overclock_settings: dict) -> "MiningModeManual":
|
||||||
# will raise KeyError if it cant find the settings, values cannot be empty
|
# will raise KeyError if it cant find the settings, values cannot be empty
|
||||||
|
|||||||
@@ -146,6 +146,15 @@ class Pool(MinerConfigValue):
|
|||||||
url=self.url, user=self.user, password=self.password, enabled=True
|
url=self.url, user=self.user, password=self.password, enabled=True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def as_vnish(self, user_suffix: str = None) -> dict:
|
||||||
|
if user_suffix is not None:
|
||||||
|
return {
|
||||||
|
"url": self.url,
|
||||||
|
"user": f"{self.user}{user_suffix}",
|
||||||
|
"pass": self.password,
|
||||||
|
}
|
||||||
|
return {"url": self.url, "user": self.user, "pass": self.password}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, dict_conf: dict | None) -> "Pool":
|
def from_dict(cls, dict_conf: dict | None) -> "Pool":
|
||||||
return cls(
|
return cls(
|
||||||
@@ -192,7 +201,7 @@ class Pool(MinerConfigValue):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def from_vnish(cls, web_pool: dict) -> "Pool":
|
def from_vnish(cls, web_pool: dict) -> "Pool":
|
||||||
return cls(
|
return cls(
|
||||||
url=web_pool["url"],
|
url="stratum+tcp://" + web_pool["url"],
|
||||||
user=web_pool["user"],
|
user=web_pool["user"],
|
||||||
password=web_pool["pass"],
|
password=web_pool["pass"],
|
||||||
)
|
)
|
||||||
@@ -338,6 +347,9 @@ class PoolGroup(MinerConfigValue):
|
|||||||
pools=[p.as_boser() for p in self.pools],
|
pools=[p.as_boser() for p in self.pools],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def as_vnish(self, user_suffix: str = None) -> dict:
|
||||||
|
return {"pools": [p.as_vnish(user_suffix=user_suffix) for p in self.pools]}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, dict_conf: dict | None) -> "PoolGroup":
|
def from_dict(cls, dict_conf: dict | None) -> "PoolGroup":
|
||||||
cls_conf = {}
|
cls_conf = {}
|
||||||
@@ -530,6 +542,9 @@ class PoolConfig(MinerConfigValue):
|
|||||||
def as_luxos(self, user_suffix: str = None) -> dict:
|
def as_luxos(self, user_suffix: str = None) -> dict:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def as_vnish(self, user_suffix: str = None) -> dict:
|
||||||
|
return self.groups[0].as_vnish(user_suffix=user_suffix)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_api(cls, api_pools: dict) -> "PoolConfig":
|
def from_api(cls, api_pools: dict) -> "PoolConfig":
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ class TemperatureConfig(MinerConfigValue):
|
|||||||
def as_luxos(self) -> dict:
|
def as_luxos(self) -> dict:
|
||||||
return {"tempctrlset": [self.target or "", self.hot or "", self.danger or ""]}
|
return {"tempctrlset": [self.target or "", self.hot or "", self.danger or ""]}
|
||||||
|
|
||||||
|
def as_vnish(self) -> dict:
|
||||||
|
return {"misc": {"restart_temp": self.danger}}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls, dict_conf: dict | None) -> "TemperatureConfig":
|
def from_dict(cls, dict_conf: dict | None) -> "TemperatureConfig":
|
||||||
return cls(
|
return cls(
|
||||||
@@ -95,9 +98,16 @@ class TemperatureConfig(MinerConfigValue):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_vnish(cls, web_settings: dict) -> "TemperatureConfig":
|
def from_vnish(cls, web_settings: dict) -> "TemperatureConfig":
|
||||||
|
try:
|
||||||
|
dangerous_temp = web_settings["misc"]["restart_temp"]
|
||||||
|
except KeyError:
|
||||||
|
dangerous_temp = None
|
||||||
try:
|
try:
|
||||||
if web_settings["miner"]["cooling"]["mode"]["name"] == "auto":
|
if web_settings["miner"]["cooling"]["mode"]["name"] == "auto":
|
||||||
return cls(target=web_settings["miner"]["cooling"]["mode"]["param"])
|
return cls(
|
||||||
|
target=web_settings["miner"]["cooling"]["mode"]["param"],
|
||||||
|
danger=dangerous_temp,
|
||||||
|
)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
return cls()
|
return cls()
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from typing import Optional
|
|||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from pydantic import BaseModel, computed_field, model_serializer
|
from pydantic import BaseModel, computed_field, model_serializer
|
||||||
|
from typing_extensions import Self
|
||||||
|
|
||||||
|
|
||||||
class Scheme(Enum):
|
class Scheme(Enum):
|
||||||
@@ -28,8 +29,10 @@ class PoolUrl(BaseModel):
|
|||||||
return f"{self.scheme.value}://{self.host}:{self.port}"
|
return f"{self.scheme.value}://{self.host}:{self.port}"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_str(cls, url: str) -> "PoolUrl":
|
def from_str(cls, url: str) -> Self | None:
|
||||||
parsed_url = urlparse(url)
|
parsed_url = urlparse(url)
|
||||||
|
if not parsed_url.hostname:
|
||||||
|
return None
|
||||||
if not parsed_url.scheme.strip() == "":
|
if not parsed_url.scheme.strip() == "":
|
||||||
scheme = Scheme(parsed_url.scheme)
|
scheme = Scheme(parsed_url.scheme)
|
||||||
else:
|
else:
|
||||||
@@ -57,15 +60,15 @@ class PoolMetrics(BaseModel):
|
|||||||
pool_stale_percent: Percentage of stale shares by the pool.
|
pool_stale_percent: Percentage of stale shares by the pool.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url: PoolUrl
|
url: PoolUrl | None
|
||||||
accepted: int = None
|
accepted: int | None = None
|
||||||
rejected: int = None
|
rejected: int | None = None
|
||||||
get_failures: int = None
|
get_failures: int | None = None
|
||||||
remote_failures: int = None
|
remote_failures: int | None = None
|
||||||
active: bool = None
|
active: bool | None = None
|
||||||
alive: bool = None
|
alive: bool | None = None
|
||||||
index: int = None
|
index: int | None = None
|
||||||
user: str = None
|
user: str | None = None
|
||||||
|
|
||||||
@computed_field # type: ignore[misc]
|
@computed_field # type: ignore[misc]
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ from pyasic import APIError
|
|||||||
from pyasic.miners.backends import BMMiner
|
from pyasic.miners.backends import BMMiner
|
||||||
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
|
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
|
||||||
from pyasic.miners.device.firmware import HiveonFirmware
|
from pyasic.miners.device.firmware import HiveonFirmware
|
||||||
|
from pyasic.web.hiveon import HiveonWebAPI
|
||||||
|
|
||||||
HIVEON_DATA_LOC = DataLocations(
|
HIVEON_DATA_LOC = DataLocations(
|
||||||
**{
|
**{
|
||||||
@@ -62,9 +63,12 @@ HIVEON_DATA_LOC = DataLocations(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Hiveon(BMMiner, HiveonFirmware):
|
class Hiveon(HiveonFirmware, BMMiner):
|
||||||
data_locations = HIVEON_DATA_LOC
|
data_locations = HIVEON_DATA_LOC
|
||||||
|
|
||||||
|
web: HiveonWebAPI
|
||||||
|
_web_cls = HiveonWebAPI
|
||||||
|
|
||||||
async def _get_wattage(self, rpc_stats: dict = None) -> Optional[int]:
|
async def _get_wattage(self, rpc_stats: dict = None) -> Optional[int]:
|
||||||
if not rpc_stats:
|
if not rpc_stats:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -98,6 +98,11 @@ class VNish(VNishFirmware, BMMiner):
|
|||||||
|
|
||||||
data_locations = VNISH_DATA_LOC
|
data_locations = VNISH_DATA_LOC
|
||||||
|
|
||||||
|
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
|
||||||
|
await self.web.post_settings(
|
||||||
|
miner_settings=config.as_vnish(user_suffix=user_suffix)
|
||||||
|
)
|
||||||
|
|
||||||
async def restart_backend(self) -> bool:
|
async def restart_backend(self) -> bool:
|
||||||
data = await self.web.restart_vnish()
|
data = await self.web.restart_vnish()
|
||||||
if data:
|
if data:
|
||||||
|
|||||||
@@ -631,7 +631,6 @@ class MinerFactory:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_web_type(web_text: str, web_resp: httpx.Response) -> MinerTypes | None:
|
def _parse_web_type(web_text: str, web_resp: httpx.Response) -> MinerTypes | None:
|
||||||
print(web_resp.headers)
|
|
||||||
if web_resp.status_code == 401 and 'realm="antMiner' in web_resp.headers.get(
|
if web_resp.status_code == 401 and 'realm="antMiner' in web_resp.headers.get(
|
||||||
"www-authenticate", ""
|
"www-authenticate", ""
|
||||||
):
|
):
|
||||||
|
|||||||
214
pyasic/web/hiveon.py
Normal file
214
pyasic/web/hiveon.py
Normal file
@@ -0,0 +1,214 @@
|
|||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Copyright 2022 Upstream Data Inc -
|
||||||
|
# -
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); -
|
||||||
|
# you may not use this file except in compliance with the License. -
|
||||||
|
# You may obtain a copy of the License at -
|
||||||
|
# -
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0 -
|
||||||
|
# -
|
||||||
|
# Unless required by applicable law or agreed to in writing, software -
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, -
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -
|
||||||
|
# See the License for the specific language governing permissions and -
|
||||||
|
# limitations under the License. -
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
import aiofiles
|
||||||
|
import httpx
|
||||||
|
|
||||||
|
from pyasic import settings
|
||||||
|
from pyasic.web.base import BaseWebAPI
|
||||||
|
|
||||||
|
|
||||||
|
class HiveonWebAPI(BaseWebAPI):
|
||||||
|
def __init__(self, ip: str) -> None:
|
||||||
|
"""Initialize the old Antminer API client with a specific IP address.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
ip (str): IP address of the Antminer device.
|
||||||
|
"""
|
||||||
|
super().__init__(ip)
|
||||||
|
self.username = "root"
|
||||||
|
self.pwd = settings.get("default_hive_web_password", "root")
|
||||||
|
|
||||||
|
async def send_command(
|
||||||
|
self,
|
||||||
|
command: str | bytes,
|
||||||
|
ignore_errors: bool = False,
|
||||||
|
allow_warning: bool = True,
|
||||||
|
privileged: bool = False,
|
||||||
|
**parameters: Any,
|
||||||
|
) -> dict:
|
||||||
|
"""Send a command to the Antminer device using HTTP digest authentication.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
command (str | bytes): The CGI command to send.
|
||||||
|
ignore_errors (bool): If True, ignore any HTTP errors.
|
||||||
|
allow_warning (bool): If True, proceed with warnings.
|
||||||
|
privileged (bool): If set to True, requires elevated privileges.
|
||||||
|
**parameters: Arbitrary keyword arguments to be sent as parameters in the request.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: The JSON response from the device or an empty dictionary if an error occurs.
|
||||||
|
"""
|
||||||
|
url = f"http://{self.ip}:{self.port}/cgi-bin/{command}.cgi"
|
||||||
|
auth = httpx.DigestAuth(self.username, self.pwd)
|
||||||
|
try:
|
||||||
|
async with httpx.AsyncClient(transport=settings.transport()) as client:
|
||||||
|
if parameters:
|
||||||
|
data = await client.post(
|
||||||
|
url,
|
||||||
|
data=parameters,
|
||||||
|
auth=auth,
|
||||||
|
timeout=settings.get("api_function_timeout", 3),
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
data = await client.get(url, auth=auth)
|
||||||
|
except httpx.HTTPError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if data.status_code == 200:
|
||||||
|
try:
|
||||||
|
return data.json()
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
async def multicommand(
|
||||||
|
self, *commands: str, ignore_errors: bool = False, allow_warning: bool = True
|
||||||
|
) -> dict:
|
||||||
|
"""Execute multiple commands simultaneously.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
*commands (str): Multiple command strings to be executed.
|
||||||
|
ignore_errors (bool): If True, ignore any HTTP errors.
|
||||||
|
allow_warning (bool): If True, proceed with warnings.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A dictionary containing the results of all commands executed.
|
||||||
|
"""
|
||||||
|
data = {k: None for k in commands}
|
||||||
|
auth = httpx.DigestAuth(self.username, self.pwd)
|
||||||
|
async with httpx.AsyncClient(transport=settings.transport()) as client:
|
||||||
|
for command in commands:
|
||||||
|
try:
|
||||||
|
url = f"http://{self.ip}/cgi-bin/{command}.cgi"
|
||||||
|
ret = await client.get(url, auth=auth)
|
||||||
|
except httpx.HTTPError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
if ret.status_code == 200:
|
||||||
|
try:
|
||||||
|
json_data = ret.json()
|
||||||
|
data[command] = json_data
|
||||||
|
except json.decoder.JSONDecodeError:
|
||||||
|
pass
|
||||||
|
return data
|
||||||
|
|
||||||
|
async def get_system_info(self) -> dict:
|
||||||
|
"""Retrieve system information from the miner.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A dictionary containing system information of the miner.
|
||||||
|
"""
|
||||||
|
return await self.send_command("get_system_info")
|
||||||
|
|
||||||
|
async def get_network_info(self) -> dict:
|
||||||
|
"""Retrieve system information from the miner.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A dictionary containing system information of the miner.
|
||||||
|
"""
|
||||||
|
return await self.send_command("get_network_info")
|
||||||
|
|
||||||
|
async def blink(self, blink: bool) -> dict:
|
||||||
|
"""Control the blinking of the LED on the miner device.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
blink (bool): True to start blinking, False to stop.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A dictionary response from the device after the command execution.
|
||||||
|
"""
|
||||||
|
if blink:
|
||||||
|
return await self.send_command("blink", action="startBlink")
|
||||||
|
return await self.send_command("blink", action="stopBlink")
|
||||||
|
|
||||||
|
async def reboot(self) -> dict:
|
||||||
|
"""Reboot the miner device.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A dictionary response from the device confirming the reboot command.
|
||||||
|
"""
|
||||||
|
return await self.send_command("reboot")
|
||||||
|
|
||||||
|
async def get_blink_status(self) -> dict:
|
||||||
|
"""Check the status of the LED blinking on the miner.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A dictionary indicating whether the LED is currently blinking.
|
||||||
|
"""
|
||||||
|
return await self.send_command("blink", action="onPageLoaded")
|
||||||
|
|
||||||
|
async def get_miner_conf(self) -> dict:
|
||||||
|
"""Retrieve the miner configuration from the Antminer device.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A dictionary containing the current configuration of the miner.
|
||||||
|
"""
|
||||||
|
return await self.send_command("get_miner_conf")
|
||||||
|
|
||||||
|
async def set_miner_conf(self, conf: dict) -> dict:
|
||||||
|
"""Set the configuration for the miner.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
conf (dict): A dictionary of configuration settings to apply to the miner.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A dictionary response from the device after setting the configuration.
|
||||||
|
"""
|
||||||
|
return await self.send_command("set_miner_conf", **conf)
|
||||||
|
|
||||||
|
async def stats(self) -> dict:
|
||||||
|
"""Retrieve detailed statistical data of the mining operation.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Detailed statistics of the miner's operation.
|
||||||
|
"""
|
||||||
|
return await self.send_command("miner_stats")
|
||||||
|
|
||||||
|
async def summary(self) -> dict:
|
||||||
|
"""Get a summary of the miner's status and performance.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: A summary of the miner's current operational status.
|
||||||
|
"""
|
||||||
|
return await self.send_command("miner_summary")
|
||||||
|
|
||||||
|
async def pools(self) -> dict:
|
||||||
|
"""Retrieve current pool information associated with the miner.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: Information about the mining pools configured in the miner.
|
||||||
|
"""
|
||||||
|
return await self.send_command("miner_pools")
|
||||||
|
|
||||||
|
async def update_firmware(self, file: Path, keep_settings: bool = True) -> dict:
|
||||||
|
"""Perform a system update by uploading a firmware file and sending a command to initiate the update."""
|
||||||
|
|
||||||
|
async with aiofiles.open(file, "rb") as firmware:
|
||||||
|
file_content = await firmware.read()
|
||||||
|
|
||||||
|
parameters = {
|
||||||
|
"file": (file.name, file_content, "application/octet-stream"),
|
||||||
|
"filename": file.name,
|
||||||
|
"keep_settings": keep_settings,
|
||||||
|
}
|
||||||
|
|
||||||
|
return await self.send_command(command="upgrade", **parameters)
|
||||||
@@ -143,3 +143,6 @@ class VNishWebAPI(BaseWebAPI):
|
|||||||
|
|
||||||
async def find_miner(self) -> dict:
|
async def find_miner(self) -> dict:
|
||||||
return await self.send_command("find-miner", privileged=True)
|
return await self.send_command("find-miner", privileged=True)
|
||||||
|
|
||||||
|
async def post_settings(self, miner_settings: dict):
|
||||||
|
return await self.send_command("settings", post=True, **miner_settings)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "pyasic"
|
name = "pyasic"
|
||||||
version = "0.64.3"
|
version = "0.64.13"
|
||||||
description = "A simplified and standardized interface for Bitcoin ASICs."
|
description = "A simplified and standardized interface for Bitcoin ASICs."
|
||||||
authors = ["UpstreamData <brett@upstreamdata.ca>"]
|
authors = ["UpstreamData <brett@upstreamdata.ca>"]
|
||||||
repository = "https://github.com/UpstreamData/pyasic"
|
repository = "https://github.com/UpstreamData/pyasic"
|
||||||
|
|||||||
Reference in New Issue
Block a user