Compare commits

...

6 Commits

Author SHA1 Message Date
UpstreamData
5ac5770331 version: bump version number. 2023-02-24 08:58:11 -07:00
UpstreamData
f131ebbdf5 bug: fix miner mode needing to be parsed as an int not a str. 2023-02-24 08:57:28 -07:00
UpstreamData
5441e50f73 version: bump version number. 2023-02-24 08:49:29 -07:00
UpstreamData
dc6a952de4 bug: fix backwards modes for X19. 2023-02-24 08:49:13 -07:00
UpstreamData
b781d215fb version: bump version number. 2023-02-24 08:44:20 -07:00
UpstreamData
086b31ba23 feature: add enum for miner mode in config. 2023-02-24 08:43:52 -07:00
3 changed files with 16 additions and 15 deletions

View File

@@ -20,12 +20,19 @@ import random
import string
import time
from dataclasses import asdict, dataclass, fields
from enum import IntEnum
from typing import Dict, List, Literal
import toml
import yaml
class X19PowerMode(IntEnum):
Normal = 0
Sleep = 1
LPM = 3
@dataclass
class _Pool:
"""A dataclass for pool information.
@@ -267,6 +274,7 @@ class MinerConfig:
asicboost: bool = None
miner_mode: IntEnum = X19PowerMode.Normal
autotuning_enabled: bool = True
autotuning_mode: Literal["power", "hashrate"] = None
autotuning_wattage: int = None
@@ -287,6 +295,8 @@ class MinerConfig:
logging.debug(f"MinerConfig - (To Dict) - Dumping Dict config")
data_dict = asdict(self)
for key in asdict(self).keys():
if isinstance(data_dict[key], IntEnum):
data_dict[key] = data_dict[key].value
if data_dict[key] is None:
del data_dict[key]
return data_dict
@@ -324,10 +334,7 @@ class MinerConfig:
self.fan_speed = int(data["bitmain-fan-pwm"])
elif key == "bitmain-work-mode":
if data[key]:
if data[key] == 1:
self.autotuning_wattage = 0
if data[key] == 2:
self.autotuning_wattage = 1200
self.miner_mode = X19PowerMode(int(data[key]))
elif key == "fan_control":
for _key in data[key].keys():
if _key == "min_fans":
@@ -459,14 +466,8 @@ class MinerConfig:
"pools": self.pool_groups[0].as_x19(user_suffix=user_suffix),
"bitmain-fan-ctrl": False,
"bitmain-fan-pwn": 100,
"miner-mode": 0, # Normal Mode
"miner-mode": self.miner_mode.value,
}
if self.autotuning_wattage:
if self.autotuning_wattage == 0:
cfg["miner-mode"] = 1 # Sleep Mode
if self.autotuning_wattage < 1800:
cfg["miner-mode"] = 3 # LPM
if not self.temp_mode == "auto":
cfg["bitmain-fan-ctrl"] = True

View File

@@ -21,7 +21,7 @@ from typing import List, Optional, Union
import httpx
from pyasic.API import APIError
from pyasic.config import MinerConfig
from pyasic.config import MinerConfig, X19PowerMode
from pyasic.data.error_codes import MinerErrorData, X19Error
from pyasic.miners._backends import BMMiner # noqa - Ignore access to _module
from pyasic.settings import PyasicSettings
@@ -101,13 +101,13 @@ class X19(BMMiner):
async def stop_mining(self) -> bool:
cfg = await self.get_config()
cfg.autotuning_wattage = 0
cfg.miner_mode = X19PowerMode.Sleep
await self.send_config(cfg)
return True
async def resume_mining(self) -> bool:
cfg = await self.get_config()
cfg.autotuning_wattage = 3600
cfg.miner_mode = X19PowerMode.Normal
await self.send_config(cfg)
return True

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyasic"
version = "0.30.6"
version = "0.30.9"
description = "A set of modules for interfacing with many common types of ASIC bitcoin miners, using both their API and SSH."
authors = ["UpstreamData <brett@upstreamdata.ca>"]
repository = "https://github.com/UpstreamData/pyasic"