Conversation
|
Verified locally: cherry-picked onto Right root cause, minimal diff. Two things before merge:
Minor note, not blocking: |
|
All three addressed.
Tests: |
The pre-sunrise branch returns before the energy balance runs, so the Charge Delay Status sensor dropped energy_needed_kwh entirely while the state was Waiting for solar. Consumers that default a missing attribute to 0 then show "0.0 kWh needed to reach 95%" at an SOC nowhere near the target. The deficit is plain SOC arithmetic and does not depend on T_start, so compute it in that branch as well, clamped at 0 so a battery already above target reports no deficit instead of a negative one. Extracted into _energy_needed_kwh() and reused at the existing call site; the delay decision itself is unchanged.
…d too
The grid-deficit hold ("Delayed (cheap import HH:MM est.)") returns
before the solar balance runs, so it dropped the attribute the same way
the Waiting-for-solar branch did, and it is evaluated first. Publish the
deficit once, before both holds, and reuse the value at the existing
call site. Adds a CHANGELOG entry under Unreleased.
A hold that returns before the solar balance runs left the previous cycle's net solar, charge time and unlock estimate in the status dict, now beside a freshly published deficit. Clear those fields where the deficit is set; each is rewritten as soon as it is computed.
5ecc6ef to
a1eff0e
Compare
…pre-sunrise fix(charge delay): publish energy_needed_kwh while waiting for solar
What
While the charge delay is holding for sunrise,
sensor.*_charge_delay_statusdroppedenergy_needed_kwh: the "No T_start detected" branch returns before the energy balanceis calculated, and the sensor omits
Noneattributes. A dashboard that defaults themissing attribute to 0 then reports "0.0 kWh needed to reach 95%" at an SOC nowhere near
the target, which reads as "nothing to do" instead of "not calculated yet".
The deficit is plain SOC arithmetic and does not depend on
T_start, so it is nowpublished in that branch too, clamped at 0 so a battery already above target reports no
deficit rather than a negative one. The expression moved into
_energy_needed_kwh()andis reused at the existing call site. The delay decision itself is unchanged.
Approved roadmap item
This is a bugfix.
Tests
uv run --with-requirements requirements-test.txt pytest tests/— 1954 passed, 10 skipped.Two new cases in
tests/test_charge_delay.py:test_waiting_for_solar_publishes_energy_needed— fails onmain(attribute absent),passes with the change.
test_waiting_for_solar_energy_needed_never_negative— battery above target reports0.0.