Skip to content

fix(fetch): compute dawn sensor regardless of combine_charge_slots - #5155

Merged
springfall2008 merged 1 commit into
mainfrom
fix/dawn-sensor-combine-charge-slots-gate
Sep 19, 2026
Merged

springfall2008 merged 1 commit into
mainfrom
fix/dawn-sensor-combine-charge-slots-gate

Conversation

@chalfontchubby

Copy link
Copy Markdown
Collaborator

🤖 This PR was written by Claude.

Summary

binary_sensor.predbat_dawn (added in #4726) was gated on switch.predbat_combine_charge_slots (off by default) as a pure no-op optimisation for the charge-window-splitting use of the same calculation. With that switch off - the default - anyone reading the sensor saw it stuck "off" all day, even in broad daylight with solar generating well above low_power_pv_threshold_w.

calc_pv_light_dark() now always computes calc_dawn()'s result. The window-splitting consumer (find_charge_window) is unaffected: with combine_charge_slots off it already forces a break every charge_slot_split minutes (the same granularity calc_dawn buckets at), so the dawn boundary could never actually be reached there - the gate was only ever a no-op for that path, never a behaviour change.

Test plan

  • ./run_all --test find_charge_window passes, including test_calc_pv_light_dark updated to assert calc_pv_light_dark() always returns calc_dawn()'s result across all combine_charge_slots/set_charge_low_power combinations
  • ./run_all --quick passes
  • ./run_pre_commit passes

binary_sensor.predbat_dawn was gated on switch.predbat_combine_charge_slots
(off by default) purely as a no-op optimisation for window splitting, so
anyone with that switch off saw the sensor read permanently "off" even in
broad daylight. calc_pv_light_dark() now always computes calc_dawn()'s
result; the window-splitting use was already a no-op in that case (a break
every charge_slot_split minutes happens regardless), so behaviour there is
unchanged.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation, tests, and documentation are consistent and cover the changed configuration behaviour.

Review effort: Lite
Findings: None

What changed in this PR

This PR makes dawn detection independent of combine_charge_slots, ensuring binary_sensor.predbat_dawn reflects the PV forecast by default.

Changes:

  • Always compute calc_dawn() results.
  • Expand tests across configuration combinations.
  • Update dawn sensor documentation.
File Description
apps/​predbat/​fetch.py Removes the dawn-calculation gate and clarifies sensor semantics.
apps/​predbat/​tests/​test_find_charge_window.py Tests dawn detection for all relevant flag combinations.
docs/​output-data.md Documents the updated sensor behaviour.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@springfall2008
springfall2008 merged commit dde2714 into main Sep 19, 2026
3 checks passed
@springfall2008
springfall2008 deleted the fix/dawn-sensor-combine-charge-slots-gate branch September 19, 2026 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants