fix(sensor): subtract EV #2 power from house consumption#541
Open
woopstar wants to merge 2 commits into
Open
Conversation
The house consumption power sensor only subtracted EV #1 from house consumption when house_power_includes_ev_charger_power was enabled. EV #2 power was never read, tracked, or included in the calculation, causing the house baseline to be inflated whenever the second EV was charging. Add full EV #2 support through the entire sensor pipeline: init, settings, state attributes, entity tracking, state fetching, and the consumption calculation itself. Fixes #323
The three _async_fetch_sensor_states tests used MagicMock(spec=...) but did not set _hsem_ev_second_charger_power, causing AttributeError when the spec mock enforced attribute access on the new field.
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.
The
HSEMHouseConsumptionPowerSensoronly subtracted EV #1 charger power from house consumption whenhouse_power_includes_ev_charger_powerwas enabled. EV #2 (configured viahsem_ev_second_charger_power) was never read, tracked, or included in the calculation — causing the house baseline and its derived energy averages (1d/3d/7d/14d) to be inflated whenever the second EV was charging.Changes
Threaded full EV #2 support through the entire sensor pipeline:
__init__— added_hsem_ev_second_charger_powerand_hsem_ev_second_charger_power_state_update_settings— readshsem_ev_second_charger_powerfrom configextra_state_attributes— exposes second EV entity + state_async_track_entities— registers state-change listener for EV Add: _hsem_battery_maximum_charging_power #2_async_fetch_sensor_states— fetches live power from EV Add: _hsem_battery_maximum_charging_power #2_async_handle_update— sums both EV powers before subtracting from house consumption_unrecorded_attributes— added new attribute keysAlso fixed three
MagicMock(spec=...)tests intest_exception_handling.pythat broke because the spec mock didn't have the new_hsem_ev_second_charger_powerattribute set.The coordinator (
state_collector.py) and planner (coordinator_builder.py) already handled both EVs correctly; this was the last gap in the EV load separation pipeline.Fixes #323