fix(inverter): auto-create charge_rate entity for script-driven "power" inverters (#3311) - #4645
Open
chalfontchubby wants to merge 1 commit into
Open
fix(inverter): auto-create charge_rate entity for script-driven "power" inverters (#3311)#4645chalfontchubby wants to merge 1 commit into
chalfontchubby wants to merge 1 commit into
Conversation
…r" inverters (#3311) Solax's low-power-mode charge rate is driven via charge_start_service (a plain HA script call), not a REST/cloud API, but output_charge_control: "power" meant the dummy charge_rate/discharge_rate entities were only ever auto-created for "current" mode. get_current_charge_rate() and adjust_charge_rate() both fall back to self.base.args["charge_rate"] regardless of output_charge_control unless the inverter is genuinely REST-driven - without the entity, the computed rate had nowhere to be stored and read back as battery_rate_max_raw, sending full power to the script regardless of what was planned. Only auto-create when nothing is already configured - unlike "current" mode (where charge_rate is always a synthetic mirror), a "power" inverter's charge_rate can be a real user-configured entity (e.g. GE's own "if not using REST" apps.yaml template) that must not be overwritten. Co-Authored-By: Claude Sonnet 5 <[email protected]>
| # was actually planned. Only fill in the gap when nothing is configured at all. | ||
| max_charge = self.battery_rate_max_charge * MINUTE_WATT | ||
| max_discharge = self.battery_rate_max_discharge * MINUTE_WATT | ||
| if "charge_rate" not in self.base.args: |
Owner
There was a problem hiding this comment.
Should this be an 'has' in the inverter config rather than silently creating missing entities?
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
battery_rate_maxinstead of the planned "Best rate" tocharge_start_service.output_charge_control: "power"inverters normally write their rate straight to the inverter via a REST/cloud API, so the dummycharge_rate/discharge_rateHA entities were only ever auto-created for"current"mode. Solax is"power"mode but script-driven (charge_start_service→ a plain HA script, not REST) -get_current_charge_rate()/adjust_charge_rate()still fall back toself.base.args["charge_rate"]exactly like"current"mode does, unless the inverter is genuinely REST-driven. Without the entity, the low-power-mode calculation runs fine (visible in the reporter's own log as "Best rate: 2500W") but has nowhere to persist it, so it reads back asbattery_rate_max_rawand the script gets sent full power. Community member f948lan independently found the same root cause and worked around it manually (creatinginput_numberhelpers) - this makes that automatic."current"mode (wherecharge_rateis always a synthetic mirror of the real current-based control, so it's always safe to (re)create), a"power"inverter'scharge_ratecan be a real, user-configured entity (e.g. GE's own apps.yaml template comment: "If not using REST then instead set the Control here") - the fix must not clobber that. Caught this exact regression while building the fix (broketest_adjust_charge_rate1against GE's default non-REST config) and tightened the condition accordingly.Test plan
./run_all --test inverter- full inverter suite passestest_low_power_mode_entity_created_for_script_driven_power_inverter- REST-less "power" inverter (Solax-shaped) gets the entity auto-createdtest_low_power_mode_entity_not_clobbered_when_already_configured- a real, pre-configuredcharge_rate(e.g. GE's own template) is left untouched, not overwrittentest_low_power_mode_entity_not_created_for_rest_driven_power_inverter- genuinely REST-driven "power" inverters are unaffected./run_pre_commitclean./run_all --quicksuite passes🤖 Generated with Claude Code