Add configurable solar grid input start and tolerance numbers #987
+73
−0
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
This PR introduces two new
numberentities to make previously hardcodedSmartModethresholds configurable:solar_grid_input_start→ controlsSmartMode.POWER_START(min 25W, max 5000W)solar_grid_input_tolerance→ controlsSmartMode.POWER_TOLERANCE(min 5W, max start - 10W)Both values are persisted via
RestoreNumberand applied automatically on startup. The tolerance entity range updates dynamically whenever the start value changes.UI labels/translations were added for en/de/fr/nl.
How the new entities override the previous hardcoded defaults
Previously, the integration relied on static defaults in
const.py:SmartMode.POWER_START = 50SmartMode.POWER_TOLERANCE = 5These constants are referenced across the codebase:
manager.pyusesSmartMode.POWER_STARTfor “start / kick-off” behavior (e.g., starting idle devices and enabling discharge of produced power).device.pyusesSmartMode.POWER_TOLERANCEas the device-level deadband inpower_charge()/power_discharge()(skip updates when the delta is within tolerance).This PR adds two new persistent (
RestoreNumber) manager-level entities:number.*_solar_grid_input_start→ updatesSmartMode.POWER_STARTnumber.*_solar_grid_input_tolerance→ updatesSmartMode.POWER_TOLERANCERuntime behavior
const.pystill provides fallback defaults (50W / 5W).RestoreEntity), the restored values are applied via the entity callbacks:update_power_start(...)setsSmartMode.POWER_STARTupdate_power_tolerance(...)setsSmartMode.POWER_TOLERANCEAs a result, the thresholds are no longer effectively hardcoded at runtime—they are overridden by the persisted HA entity values.
Constraints / clamping
solar_grid_input_start: 25W … 5000Wsolar_grid_input_tolerance: 5W … (start - 10W)Why keep the constants in
const.py?They serve as safe defaults for fresh installs (no restored state yet) and avoid refactoring all existing call sites that reference
SmartMode.POWER_START/SmartMode.POWER_TOLERANCE.