From 09bc9686ae947f91c17278cceb22d2d7751e6f03 Mon Sep 17 00:00:00 2001 From: b-rowan Date: Sat, 10 Feb 2024 14:23:17 -0700 Subject: [PATCH] feature: add support for goldshell mode settings. --- pyasic/config/mining.py | 9 +++++++++ pyasic/miners/backends/goldshell.py | 9 +++++++-- pyasic/web/goldshell.py | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/pyasic/config/mining.py b/pyasic/config/mining.py index 3cf35233..cb968949 100644 --- a/pyasic/config/mining.py +++ b/pyasic/config/mining.py @@ -50,6 +50,9 @@ class MiningModeNormal(MinerConfigValue): def as_epic(self) -> dict: return {"ptune": {"enabled": False}} + def as_goldshell(self) -> dict: + return {"settings": {"select": 0}} + @dataclass class MiningModeSleep(MinerConfigValue): @@ -71,6 +74,9 @@ class MiningModeSleep(MinerConfigValue): def as_epic(self) -> dict: return {"ptune": {"algo": "Sleep", "target": 0}} + def as_goldshell(self) -> dict: + return {"settings": {"select": 2}} + @dataclass class MiningModeLPM(MinerConfigValue): @@ -89,6 +95,9 @@ class MiningModeLPM(MinerConfigValue): def as_auradine(self) -> dict: return {"mode": {"mode": "eco"}} + def as_goldshell(self) -> dict: + return {"settings": {"select": 1}} + @dataclass class MiningModeHPM(MinerConfigValue): diff --git a/pyasic/miners/backends/goldshell.py b/pyasic/miners/backends/goldshell.py index df9281ea..9c070530 100644 --- a/pyasic/miners/backends/goldshell.py +++ b/pyasic/miners/backends/goldshell.py @@ -96,13 +96,18 @@ class GoldshellMiner(BFGMiner): ) self.config = config - + cfg = config.as_goldshell(user_suffix=user_suffix) # send them back 1 at a time - for pool in config.as_goldshell(user_suffix=user_suffix)["pools"]: + for pool in cfg["pools"]: await self.web.newpool( url=pool["url"], user=pool["user"], password=pool["pass"] ) + settings = await self.web.setting() + for new_setting in cfg["settings"]: + settings[new_setting] = cfg["settings"][new_setting] + await self.web.set_setting(settings) + async def _get_mac(self, web_setting: dict = None) -> str: if web_setting is None: try: diff --git a/pyasic/web/goldshell.py b/pyasic/web/goldshell.py index db28e52b..200707fb 100644 --- a/pyasic/web/goldshell.py +++ b/pyasic/web/goldshell.py @@ -138,5 +138,8 @@ class GoldshellWebAPI(BaseWebAPI): async def setting(self) -> dict: return await self.send_command("setting") + async def set_setting(self, values: dict): + await self.send_command("setting", **values) + async def status(self) -> dict: return await self.send_command("status")