Repository navigation
Commit 52d2fcd
fix: Treat charger as 0A when OFF to enable proper start logic in EV_FREE mode (v0.9.10)
CRITICAL FIX: Charger now starts correctly when OFF during EV_FREE priority with solar surplus.
USER INSIGHT:
User correctly identified: "If priority switches from HOME to EV_FREE it should start charging"
This revealed that v0.9.9 was incomplete - only fixed early return, not the comparison logic.
ROOT CAUSE:
When charger is OFF, the system was reading the stored amperage setting (e.g., 16A from
previous session) instead of treating the OFF state as 0A for comparison purposes.
Scenario that failed:
1. Priority = HOME → EV charger STOPPED (home battery charging)
2. Priority switches to EV_FREE → both targets met, solar surplus available (6000W)
3. System reads current_amps = 16A (stored setting)
4. Calculates target_amps = 26A (from solar surplus)
5. Comparison: 26A > 16A = TRUE → should start (CORRECT)
BUT if surplus was lower:
3. System reads current_amps = 16A (stored setting)
4. Calculates target_amps = 6A (low solar surplus)
5. Comparison: 6A > 16A = FALSE → no action taken (WRONG - should have started at 6A)
THE COMPLETE FIX:
Modified solar_surplus.py lines 557-573 to check charger switch state BEFORE reading amperage:
- If charger is ON: Read actual amperage from sensor (normal operation)
- If charger is OFF: Set current_amps = 0 (allows any surplus to trigger start)
Now the comparison at line 677 works correctly:
- target_amps (6A or 26A) > current_amps (0A) = TRUE
- Calls _set_amperage() which starts charger at target amperage
IMPACT:
✅ Priority transitions HOME → EV_FREE now start charging automatically
✅ Fresh installations with charger OFF now work correctly
✅ ALL surplus levels (even 6A minimum) trigger charger start when OFF
✅ Proper state machine: OFF (0A) → any surplus → ON at calculated amperage
This completes the fix started in v0.9.9 (fall-through logic) with proper amperage handling.
Files Changed:
- custom_components/ev_smart_charger/solar_surplus.py (lines 557-573)
- custom_components/ev_smart_charger/manifest.json (version 0.9.10)
- README.md (version + detailed changelog explaining both fixes)
🎯 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent a9f6940 commit 52d2fcd
3 files changed
Lines changed: 53 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
729 | 729 | | |
730 | 730 | | |
731 | 731 | | |
732 | | - | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
733 | 768 | | |
734 | 769 | | |
735 | 770 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
563 | 570 | | |
564 | 571 | | |
565 | | - | |
| 572 | + | |
| 573 | + | |
566 | 574 | | |
567 | 575 | | |
568 | 576 | | |
| |||
0 commit comments