Persist winter price brake offset and apply to control temperature#194
Merged
JohanAlvedal merged 1 commit intocodex/01from Jan 20, 2026
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Motivation
WINTER_BRAKE_THRESHOLDusing the existingWINTER_BRAKE_TEMP_OFFSET.brake_target_c,brake_offset_c, andcontrol_outdoor_temperatureat runtime.Description
Store(_brake_offset_store) and persistence helpersasync_load/async_savewrappers via_load_brake_offsetand_persist_brake_offsetto holdbrake_offset_cacross restarts.price_pressure = clamp(price_factor_percent / 100, 0, 1)andbrake_target_c = price_pressure * WINTER_BRAKE_TEMP_OFFSET(applied only whensensor_data["outdoor_temp"] <= WINTER_BRAKE_THRESHOLD), then rate-limit the appliedbrake_offset_cusing the existingapply_rate_limit.control_outdoor_temperature = fake_temp + brake_offset_cand clamp that final control temperature withinMIN_FAKE_TEMP..MAX_FAKE_TEMPbefore passing it into_apply_control_bias.brake_target_c,brake_offset_c, andcontrol_outdoor_temperatureare populated in the sensor attributes for visibility.Storestub in test helpers so unit tests can run without a full Home Assistant runtime.Note: the implementation uses only the existing constants
WINTER_BRAKE_TEMP_OFFSET,WINTER_BRAKE_THRESHOLD,MIN_FAKE_TEMP, andMAX_FAKE_TEMPas requested.Testing
pytestagainst the repository test suite; final result:31 passed.homeassistant.helpers.storagein the test stubs, which was resolved by adding a minimalStorestub; after that all tests passed.Explanation of the true control signal: the effective control value sent to the heat pump is the PI-adjusted temperature
adjusted_tempwhich is assigned to the sensor viaself._attr_native_valueaftercontrol_outdoor_temperature(which includesbrake_offset_c) is run through_apply_control_bias.Codex Task