Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f2223a112 | ||
|
|
50e6cf9dfd | ||
|
|
1b5e3093e6 | ||
|
|
9e3578b4a2 | ||
|
|
a3087e1a96 | ||
|
|
4b16ea2ca2 |
6
.github/workflows/python-publish.yml
vendored
6
.github/workflows/python-publish.yml
vendored
@@ -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 }}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user