refactor: simplify get_wattage_limit for luxos
This commit is contained in:
committed by
Brett Rowan
parent
957981a9c6
commit
8e2ad478e9
@@ -24,6 +24,7 @@ from pyasic.errors import APIError
|
|||||||
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
|
from pyasic.miners.data import DataFunction, DataLocations, DataOptions, RPCAPICommand
|
||||||
from pyasic.miners.device.firmware import LuxOSFirmware
|
from pyasic.miners.device.firmware import LuxOSFirmware
|
||||||
from pyasic.rpc.luxminer import LUXMinerRPCAPI
|
from pyasic.rpc.luxminer import LUXMinerRPCAPI
|
||||||
|
from pyasic.config.mining_mode import MiningModePreset
|
||||||
|
|
||||||
LUXMINER_DATA_LOC = DataLocations(
|
LUXMINER_DATA_LOC = DataLocations(
|
||||||
**{
|
**{
|
||||||
@@ -49,7 +50,10 @@ LUXMINER_DATA_LOC = DataLocations(
|
|||||||
),
|
),
|
||||||
str(DataOptions.WATTAGE_LIMIT): DataFunction(
|
str(DataOptions.WATTAGE_LIMIT): DataFunction(
|
||||||
"_get_wattage_limit",
|
"_get_wattage_limit",
|
||||||
[],
|
[
|
||||||
|
RPCAPICommand("rpc_config", "config"),
|
||||||
|
RPCAPICommand("rpc_profiles", "profiles"),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
str(DataOptions.FANS): DataFunction(
|
str(DataOptions.FANS): DataFunction(
|
||||||
"_get_fans",
|
"_get_fans",
|
||||||
@@ -293,12 +297,14 @@ class LUXMiner(LuxOSFirmware):
|
|||||||
except (LookupError, ValueError, TypeError):
|
except (LookupError, ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def _get_wattage_limit(self) -> Optional[int]:
|
async def _get_wattage_limit(
|
||||||
config = await self.get_config()
|
self, rpc_config: dict = None, rpc_profiles: list[dict] = None
|
||||||
|
) -> Optional[int]:
|
||||||
if config is not None:
|
|
||||||
try:
|
try:
|
||||||
return int(config.mining_mode.active_preset.power)
|
active_preset = MiningModePreset.get_active_preset_from_luxos(
|
||||||
|
rpc_config, rpc_profiles
|
||||||
|
)
|
||||||
|
return active_preset.power
|
||||||
except (LookupError, ValueError, TypeError):
|
except (LookupError, ValueError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user