Skip to content

Commit 6490894

Browse files
committed
Update CLAUDE.md with number entity defaults fix and test coverage
https://claude.ai/code/session_01P9LAQ5ET6SU9dLWULxv2uF
1 parent fbbeed5 commit 6490894

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

CLAUDE.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,19 @@ prices, PV forecast, deficit, overrides, power) — when unchanged
553553
AND we're still in the same slot, the algorithm is not re-run.
554554
Recomputed on slot boundaries. Cuts CPU on the 10-second tick.
555555

556+
#### C5. Number Entity Default Values — IMPLEMENTED
557+
`HA_FelicityInternalNumber` now accepts a `default_value` parameter.
558+
When an option key is missing from `entry.options` (new installation
559+
or upgrade that predates the option), `native_value` returns the
560+
default instead of `None`. HA renders `None` as greyed-out /
561+
unavailable — this caused `max_amperage_per_phase` (and potentially
562+
other entities) to be unusable on fresh installs.
563+
`_get_default_options()` in `config_flow.py` now includes all option
564+
keys (`max_amperage_per_phase`, `safe_power_management`,
565+
`battery_cycle_cost_eur_kwh`, `optimization_priority`,
566+
`block_export_on_negative_price`) so new installations get them
567+
written at setup time.
568+
556569
### Deferred Items (Need Separate Iteration)
557570

558571
These were flagged in the same review but require larger changes
@@ -597,7 +610,7 @@ specific time windows.
597610

598611
## Testing
599612

600-
Tests are in `tests/test_ems.py` (146 tests). They import `ems.py` directly (bypassing HA dependencies) and test the pure scheduling functions.
613+
Tests are in `tests/test_ems.py` (148 tests). They import `ems.py` directly (bypassing HA dependencies) and test the pure scheduling functions.
601614

602615
```bash
603616
# Run all tests
@@ -621,6 +634,13 @@ python -m pytest tests/test_ems.py::TestSolarProtection -v
621634
- Both-mode sell with charge energy (low PV confidence)
622635
- Integration tests: real-world TREX-5/10/25/50 scenarios
623636
- Tomorrow schedule computation and SOC trajectory
637+
- Urgent recovery charging (SOC below discharge_min)
638+
- Battery cycle cost in profitability filter
639+
- Optimization priority (longevity, self_consumption)
640+
- Block export on negative price
641+
- PV confidence EMA smoothing
642+
- PV forecast fallback
643+
- Phantom charge prevention (tomorrow schedule, full battery)
624644

625645
**Not tested**: coordinator.py runtime logic (requires HA mocking). This is a gap — when the coordinator diverges from ems.py, tests won't catch it.
626646

0 commit comments

Comments
 (0)