Commit 67d23d8
Antonio ...
fix: Critical Night Smart Charge sunrise termination bug (v1.3.17)
CRITICAL BUG FIX: Night charging could continue indefinitely past sunrise
Root Cause Analysis:
- BATTERY mode had monitoring loop but NO sunrise termination check
- GRID mode had NO monitoring loop at all (zero autonomous stop conditions)
- Active sessions bypassed periodic window checks
- User reported charging notification at 08:40 AM (90 min after sunrise)
Changes Made:
1. BATTERY Mode Enhanced
- Added sunrise check to existing monitoring loop (every 15s)
- Stops immediately when window closes (sunrise occurs)
- Maintains existing home battery SOC and EV target checks
2. GRID Mode Monitoring Loop Created (NEW)
- Complete monitoring loop added (previously missing)
- Checks every 15 seconds for:
* Sunrise termination (window closed)
* EV target SOC reached
* Charger status validation
- Registered in _start_grid_charge()
3. Periodic Check Enhanced
- Active sessions now re-validate window validity
- Prevents sunrise bypass for running sessions
- Terminates sessions detected outside valid window
4. Enhanced Logging
- Detailed window comparison logging (Now >= Scheduled, Now < Sunrise)
- Debug-level logging for frequent monitoring checks
- Helps diagnose future window-related issues
Stop Conditions Fixed:
- BATTERY mode: Now stops at sunrise ✅ (was missing ❌)
- GRID mode: Now stops at sunrise ✅ (was missing ❌)
- GRID mode: Now stops when EV target reached ✅ (was missing ❌)
Technical Details:
- Added _grid_monitor_unsub timer tracking
- Both modes check _is_in_active_window() every 15s
- Session completion cancels both monitoring loops
- Grid monitoring uses same 15s interval as battery mode
Files Modified:
- night_smart_charge.py: Added GRID monitoring loop, sunrise checks
- const.py: VERSION = "1.3.17"
- manifest.json: version = "1.3.17"
- CLAUDE.md: Release notes with detailed analysis
- NIGHT_CHARGE_SCENARIOS.md: Complete scenario documentation
User Impact:
🔴 URGENT UPGRADE - Prevents:
- Night charging continuing past sunrise
- Unexpected grid charging when solar available
- Overcharging when EV target already reached
Related: User bug report (08:40 AM charging notification)1 parent 95d6c03 commit 67d23d8
5 files changed
Lines changed: 744 additions & 8 deletions
File tree
- custom_components/ev_smart_charger
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
753 | 753 | | |
754 | 754 | | |
755 | 755 | | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
756 | 822 | | |
757 | 823 | | |
758 | 824 | | |
| |||
0 commit comments