Compare commits

...

6 Commits

Author SHA1 Message Date
Brett Rowan
2f2223a112 version: bump version number 2024-12-16 20:06:33 -07:00
Wilfred Allyn
50e6cf9dfd feature: add supports_autotuning to vnish 2024-12-16 07:43:15 -07:00
Wilfred Allyn
1b5e3093e6 feature: set power to highest preset <= wattage 2024-12-16 07:43:15 -07:00
Wilfred Allyn
9e3578b4a2 feature: check vnish presets when set power 2024-12-16 07:43:15 -07:00
Wilfred Allyn
a3087e1a96 set vnish power limit 2024-12-16 07:43:15 -07:00
Brett Rowan
4b16ea2ca2 ci: update publish action 2024-12-10 13:55:30 -07:00
4 changed files with 39 additions and 4 deletions

View File

@@ -13,10 +13,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4.2.2
- name: Publish GH release
uses: softprops/action-gh-release@v0.1.14
uses: softprops/action-gh-release@v2.1.0
- name: Build using poetry and publish to PyPi
uses: JRubics/poetry-publish@v1.11
uses: JRubics/poetry-publish@v2.0
with:
pypi_token: ${{ secrets.PYPI_API_KEY }}

View File

@@ -14,6 +14,7 @@
# limitations under the License. -
# ------------------------------------------------------------------------------
import logging
from typing import Optional
from pyasic import MinerConfig
@@ -96,6 +97,7 @@ class VNish(VNishFirmware, BMMiner):
supports_shutdown = True
supports_presets = True
supports_autotuning = True
data_locations = VNISH_DATA_LOC
@@ -272,3 +274,27 @@ class VNish(VNishFirmware, BMMiner):
return self.config
self.config = MinerConfig.from_vnish(web_settings, web_presets)
return self.config
async def set_power_limit(self, wattage: int) -> bool:
config = await self.get_config()
valid_presets = [
preset.power
for preset in config.mining_mode.available_presets
if preset.tuned and preset.power <= wattage
]
new_wattage = max(valid_presets)
# Set power to highest preset <= wattage
try:
await self.web.set_power_limit(new_wattage)
updated_settings = await self.web.settings()
except APIError:
raise
except Exception as e:
logging.warning(f"{self} - Failed to set power limit: {e}")
return False
if int(updated_settings["miner"]["overclock"]["preset"]) == new_wattage:
return True
else:
return False

View File

@@ -138,6 +138,15 @@ class VNishWebAPI(BaseWebAPI):
async def settings(self) -> dict:
return await self.send_command("settings")
async def set_power_limit(self, wattage: int) -> bool:
# Can only set power limit to tuned preset
settings = await self.settings()
settings["miner"]["overclock"]["preset"] = str(wattage)
new_settings = {"miner": {"overclock": settings["miner"]["overclock"]}}
# response will always be {"restart_required":false,"reboot_required":false} even if unsuccessful
return await self.send_command("settings", privileged=True, **new_settings)
async def autotune_presets(self) -> dict:
return await self.send_command("autotune/presets")

View File

@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyasic"
version = "0.65.8"
version = "0.66.0"
description = "A simplified and standardized interface for Bitcoin ASICs."
authors = ["UpstreamData <brett@upstreamdata.ca>"]
repository = "https://github.com/UpstreamData/pyasic"