Skip to content

Cheapest Energy Windows - v1.0.6

Choose a tag to compare

@cheapest-energy-windows cheapest-energy-windows released this 24 Nov 12:30

🐛 Bug Fixes

1. Time Override Window Calculation - Fixed Incorrect Window Counts

Fixed: Time override now properly affects the initial window calculation, not just the actual windows.

  • Issue: When setting time override to "idle" for most of the day (e.g., 12:00 AM - 11:30 PM), the display showed "0/95" charge windows instead of "0/0". The first number (actual windows after override) was correct, but the second number (calculated windows) incorrectly showed 95 windows.

    • Example: Time Override Tomorrow set to "idle" from 12:00 AM - 11:30 PM showed "Charge 0/95" and "Discharge 0/0"
    • Root Cause: Window calculation didn't consider time overrides when initially selecting windows, only applied them as a filter afterward
    • Additional Issue: Time entity values weren't properly converted to string format, causing pre-filtering to be skipped on first enable
  • File: calculation_engine.py (Lines 107-161, 113-133, 727-745)

  • Changes:

    • Added pre-filtering logic before _find_charge_windows() and _find_discharge_windows()
    • When time override is set to IDLE/OFF, those time periods are excluded from available prices before calculating windows
    • When time override is set to CHARGE, only override periods are considered for charge windows
    • When time override is set to DISCHARGE, only override periods are considered for discharge windows
    • Added time entity format conversion to handle both datetime objects and strings
    • This ensures the initial window calculation respects time overrides, resulting in consistent window counts
  • Impact:

    • Display now correctly shows "0/0" when override prevents all windows
    • Both calculated and actual window counts properly reflect time override settings
    • Time override works immediately without needing to toggle modes
    • More intuitive behavior that matches user expectations

2. Service Cleanup on Integration Unload

Fixed: Services are now properly unregistered when the integration is unloaded, preventing memory leaks and duplicate service registration errors.

  • File: __init__.py (Lines 133-137)

3. Improved Battery Action Text Entity Initialization

Fixed: Battery action text entities now consistently read from config_entry.options for better code maintainability.

  • File: text.py (Lines 100, 109, 118, 127, 136)
  • Note: Code quality improvement, no functional change

4. Reduced Excessive Logging

Fixed: Changed 23 diagnostic log lines from warning/info to debug level, dramatically reducing log spam.

  • File: calculation_engine.py
  • Impact: Logs only appear when debug logging is enabled

5. ApexCharts Refresh After Integration Reload

Fixed: Dashboard now properly refreshes after integration reload by clearing persistent coordinator state.

  • File: __init__.py (Lines 126-130)

6. Time Override Toggle Updates

Fixed: Both enabling and disabling time override now trigger immediate dashboard updates.

  • File: sensor.py (Lines 165-171)
  • Changed: From incorrect time_override_1/2/3_enabled to correct time_override_enabled

7. Improved Price Sensor Setup Message

Fixed: Setup error message now accurately lists both supported price sensors instead of only mentioning Nordpool.

  • Files: config_flow.py (Line 150), strings.json (Line 138), translations/en.json (Line 138)
  • Changed: Updated from "install the Nordpool integration from HACS" to list both Nordpool and ENTSO-E
  • Improved: Clarified both sensors are available from HACS, added attribute requirements for each sensor type

📋 Upgrade Instructions

⚠️ IMPORTANT: Restart Required

  1. Update through HACS
  2. Restart Home Assistant (Settings → System → Restart)
    • Do NOT just reload the integration
    • Full restart ensures all fixes are properly applied