Add set_profile method to LuxOS#409
Open
wilfredallyn wants to merge 5 commits intoUpstreamData:masterfrom
Open
Add set_profile method to LuxOS#409wilfredallyn wants to merge 5 commits intoUpstreamData:masterfrom
set_profile method to LuxOS#409wilfredallyn wants to merge 5 commits intoUpstreamData:masterfrom
Conversation
Add set_preset(name) method to LUXMiner for switching mining presets by name. Validates preset against available presets before making RPC calls. Refactored the ATM disable/re-enable logic shared by set_preset() and set_power_limit() into a private _switch_profile() helper. This fixes a bug in set_power_limit() where ATM could stay disabled if the profile switch failed (the re-enable was inside the same try block as the switch). The new _switch_profile() uses a finally block to ensure ATM is always re-enabled if it was disabled, regardless of whether the profile switch succeeds or fails.
Rename public API to match LuxOS terminology. Accept flexible input: "190", "190mhz", or "190MHz" all resolve to the correct firmware profile name.
for more information, see https://pre-commit.ci
wilfredallyn
commented
Feb 10, 2026
| pass | ||
| return None | ||
|
|
||
| async def _switch_profile(self, profile_name: str) -> dict: |
Contributor
Author
There was a problem hiding this comment.
Created helper method that disables and re-enables ATM so don’t duplicate logic in methods that need to do this
| ) | ||
|
|
||
| @staticmethod | ||
| def _match_profile_name(name: str, profile_names: list[str]) -> str | None: |
Contributor
Author
There was a problem hiding this comment.
When calling set_profile, will accept 190MHz, 190mhz, or 190
| result = await self.rpc.profileset(new_preset) | ||
| if re_enable_atm: | ||
| await self.rpc.atmset(enabled=True) | ||
| result = await self._switch_profile(new_preset) |
Contributor
Author
There was a problem hiding this comment.
Updated set_power_limit to use helper method _switch_profile
Contributor
Author
|
I went back and forth between naming it |
Collaborator
|
Set profile is fine, I don't think it matters. In theory you could add them both and have one point to the other if you want. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
set_profile(name: str) -> boolmethod to the LuxOS backend for programmatic switching between profiles (e.g.,190MHz,415MHz,565MHz).Follows same pattern as
set_power_limit()method, including ATM (Advanced Thermal Management) handling.Motivation
I want to be able to select a profile in Home Assistant using hass-miner. Currently, it only allows choosing a wattage. Adding
set_profileis necessary for hass-miner to be able to select a profile.Changes
pyasic/miners/backends/luxminer.py
pyasic/miners/base.py
Tests
a. Switches profile with ATM enabled (disable → switch → re-enable)
b. Switches profile with ATM disabled (no ATM toggling)
c. Returns False for invalid profile name (no RPC call made)
d. Returns True + logs warning when ATM re-enable fails
e. Fuzzy matches case-insensitive input ("190mhz" → "190MHz")
f. Fuzzy matches number-only input ("190" → "190MHz")
g. Returns False when rpc.profileset() raises an exception
Usage
Testing