feature: add set_power_limit to all miners that support it.
This commit is contained in:
@@ -117,10 +117,11 @@ These functions are
|
|||||||
[`get_hostname`](#get-hostname),
|
[`get_hostname`](#get-hostname),
|
||||||
[`get_model`](#get-model),
|
[`get_model`](#get-model),
|
||||||
[`reboot`](#reboot),
|
[`reboot`](#reboot),
|
||||||
[`restart_backend`](#restart-backend), and
|
[`restart_backend`](#restart-backend),
|
||||||
[`stop_mining`](#stop-mining), and
|
[`stop_mining`](#stop-mining),
|
||||||
[`resume_mining`](#resume-mining), and
|
[`resume_mining`](#resume-mining),
|
||||||
[`send_config`](#send-config).
|
[`send_config`](#send-config), and
|
||||||
|
[`set_power_limit`](#set-power-limit).
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
@@ -228,6 +229,14 @@ These functions are
|
|||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
### Set Power Limit
|
||||||
|
::: pyasic.miners.BaseMiner.set_power_limit
|
||||||
|
handler: python
|
||||||
|
options:
|
||||||
|
heading_level: 4
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
## [`MinerConfig`][pyasic.config.MinerConfig] and [`MinerData`][pyasic.data.MinerData]
|
## [`MinerConfig`][pyasic.config.MinerConfig] and [`MinerData`][pyasic.data.MinerData]
|
||||||
|
|
||||||
Pyasic implements a few dataclasses as helpers to make data return types consistent across different miners and miner APIs. The different fields of these dataclasses can all be viewed with the classmethod `cls.fields()`.
|
Pyasic implements a few dataclasses as helpers to make data return types consistent across different miners and miner APIs. The different fields of these dataclasses can all be viewed with the classmethod `cls.fields()`.
|
||||||
|
|||||||
@@ -349,3 +349,7 @@ class BMMiner(BaseMiner):
|
|||||||
data.pool_split = str(quota)
|
data.pool_split = str(quota)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
async def set_power_limit(self, wattage: int) -> bool:
|
||||||
|
return False
|
||||||
|
|||||||
@@ -671,3 +671,14 @@ class BOSMiner(BaseMiner):
|
|||||||
async def get_mac(self):
|
async def get_mac(self):
|
||||||
result = await self.send_ssh_command("cat /sys/class/net/eth0/address")
|
result = await self.send_ssh_command("cat /sys/class/net/eth0/address")
|
||||||
return result.upper().strip()
|
return result.upper().strip()
|
||||||
|
|
||||||
|
async def set_power_limit(self, wattage: int) -> bool:
|
||||||
|
try:
|
||||||
|
cfg = await self.get_config()
|
||||||
|
cfg.autotuning_wattage = wattage
|
||||||
|
await self.send_config(cfg)
|
||||||
|
except Exception as e:
|
||||||
|
logging.warning(f"{self} set_power_limit: {e}")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|||||||
@@ -106,3 +106,6 @@ class BOSMinerOld(BaseMiner):
|
|||||||
|
|
||||||
async def get_data(self, **kwargs) -> MinerData:
|
async def get_data(self, **kwargs) -> MinerData:
|
||||||
return MinerData(ip=str(self.ip))
|
return MinerData(ip=str(self.ip))
|
||||||
|
|
||||||
|
async def set_power_limit(self, wattage: int) -> bool:
|
||||||
|
return False
|
||||||
|
|||||||
@@ -438,3 +438,13 @@ class BTMiner(BaseMiner):
|
|||||||
data.mac = mac
|
data.mac = mac
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
async def set_power_limit(self, wattage: int) -> bool:
|
||||||
|
try:
|
||||||
|
await self.api.adjust_power_limit(wattage)
|
||||||
|
except Exception as e:
|
||||||
|
logging.warning(f"{self} set_power_limit: {e}")
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|||||||
@@ -335,3 +335,6 @@ class CGMiner(BaseMiner):
|
|||||||
data.pool_split = str(quota)
|
data.pool_split = str(quota)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
async def set_power_limit(self, wattage: int) -> bool:
|
||||||
|
return False
|
||||||
|
|||||||
@@ -61,3 +61,6 @@ class Hiveon(BMMiner):
|
|||||||
bad_boards[board] = []
|
bad_boards[board] = []
|
||||||
bad_boards[board].append(chain)
|
bad_boards[board].append(chain)
|
||||||
return bad_boards
|
return bad_boards
|
||||||
|
|
||||||
|
async def set_power_limit(self, wattage: int) -> bool:
|
||||||
|
return False
|
||||||
|
|||||||
@@ -216,4 +216,12 @@ class BaseMiner(ABC):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
async def set_power_limit(self, wattage: int) -> bool:
|
||||||
|
"""Set the power limit to be used by the miner.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A boolean value of the success of setting the power limit.
|
||||||
|
"""
|
||||||
|
|
||||||
AnyMiner = TypeVar("AnyMiner", bound=BaseMiner)
|
AnyMiner = TypeVar("AnyMiner", bound=BaseMiner)
|
||||||
|
|||||||
@@ -74,3 +74,6 @@ class UnknownMiner(BaseMiner):
|
|||||||
|
|
||||||
async def get_data(self, allow_warning: bool = False) -> MinerData:
|
async def get_data(self, allow_warning: bool = False) -> MinerData:
|
||||||
return MinerData(ip=str(self.ip))
|
return MinerData(ip=str(self.ip))
|
||||||
|
|
||||||
|
async def set_power_limit(self, wattage: int) -> bool:
|
||||||
|
return False
|
||||||
|
|||||||
Reference in New Issue
Block a user