feature: add support for setting wattage on whatsminers with the new 2.0.5 API

This commit is contained in:
UpstreamData
2022-11-24 09:56:25 -07:00
parent ff2c083a19
commit e873fa252c
2 changed files with 20 additions and 14 deletions

View File

@@ -17,7 +17,7 @@ import random
import string import string
import time import time
from dataclasses import asdict, dataclass, fields from dataclasses import asdict, dataclass, fields
from typing import List, Literal from typing import List, Literal, Dict
import toml import toml
import yaml import yaml
@@ -193,7 +193,7 @@ class _PoolGroup:
return pools return pools
def as_wm(self, user_suffix: str = None) -> List[dict]: def as_wm(self, user_suffix: str = None) -> List[dict]:
"""Convert the data in this class to a list usable by an Whatsminer device. """Convert the data in this class to a list usable by a Whatsminer device.
Parameters: Parameters:
user_suffix: The suffix to append to username. user_suffix: The suffix to append to username.
@@ -399,13 +399,13 @@ class MinerConfig:
""" """
return self.from_dict(yaml.load(data, Loader=yaml.SafeLoader)) return self.from_dict(yaml.load(data, Loader=yaml.SafeLoader))
def as_wm(self, user_suffix: str = None) -> List[dict]: def as_wm(self, user_suffix: str = None) -> Dict[str: List[dict], str: int]:
"""Convert the data in this class to a config usable by an Whatsminer device. """Convert the data in this class to a config usable by a Whatsminer device.
Parameters: Parameters:
user_suffix: The suffix to append to username. user_suffix: The suffix to append to username.
""" """
return self.pool_groups[0].as_wm(user_suffix=user_suffix) return {"pools": self.pool_groups[0].as_wm(user_suffix=user_suffix), "wattage": self.autotuning_wattage}
def as_inno(self, user_suffix: str = None) -> dict: def as_inno(self, user_suffix: str = None) -> dict:
"""Convert the data in this class to a config usable by an Innosilicon device. """Convert the data in this class to a config usable by an Innosilicon device.

View File

@@ -211,18 +211,24 @@ class BTMiner(BaseMiner):
async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None: async def send_config(self, config: MinerConfig, user_suffix: str = None) -> None:
conf = config.as_wm(user_suffix=user_suffix) conf = config.as_wm(user_suffix=user_suffix)
pools_conf = conf["pools"]
await self.api.update_pools( await self.api.update_pools(
conf[0]["url"], pools_conf[0]["url"],
conf[0]["user"], pools_conf[0]["user"],
conf[0]["pass"], pools_conf[0]["pass"],
conf[1]["url"], pools_conf[1]["url"],
conf[1]["user"], pools_conf[1]["user"],
conf[1]["pass"], pools_conf[1]["pass"],
conf[2]["url"], pools_conf[2]["url"],
conf[2]["user"], pools_conf[2]["user"],
conf[2]["pass"], pools_conf[2]["pass"],
) )
try:
await self.api.adjust_power_limit(conf["wattage"])
except APIError:
# cannot set wattage
pass
async def get_config(self) -> MinerConfig: async def get_config(self) -> MinerConfig:
pools = None pools = None