EV-20: Car Solar mode, spare sun to the car (charging only)
checks / unit (pull_request) Successful in 57m6s
infra-pin / fresh (pull_request) Successful in 3s

Solar as a second writer next to Manual (carmode.SolarPlan, SolarWriter on
ManualWriter's one write site, safe phase sequence and other-writer watch):
signed spare, Batteries first on the batteries' ratings, the margin, whole
amps rounded down, the 30 s / 1 A rule, start and pause dwells, auto phases,
a one-phase car. Every way out ends at 0 A, retried by EV-04's rule; at
shutdown before the inverters, three tries inside 15 s (D3); start-up and a
returning charger or HA write 0 A first (D2); never over another writer's
hold. The peak guard treats a Solar car as a Manual car (D1 wording). Solar
kWh sensor and card line; select.goodwe_car_sun_first; ev_margin_w,
ev_start_min, ev_pause_min with config, validator, translations, DOCS,
DECISIONS and CHANGELOG.

Checks: test_ev20.py, test_ev20_exits.py, test_ev20_writers.py,
test_ev20_guard.py, test_ev20_long.py, test_ev20_long_car.py,
test_ev20_fuzz.py (harness tools/ev20_sun.py, ev20_kit.py, ev20_day.py);
test_ev03/test_ev04 no longer use Solar as the refused example.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
Claude
2026-11-22 20:31:26 +01:00
parent 885528ab48
commit 226e5a1e8b
35 changed files with 4647 additions and 123 deletions
+73 -10
View File
@@ -256,7 +256,10 @@ The label and description each setting shows on the Configuration tab, in tab or
| Car charger | Charger limit (A) | `ev_max_a` | The most current the charger may ever be asked for. Never above what the charger reports. Lower it for a weaker fuse or cable. |
| Car charger | Phases | `ev_phases` | How many phases the charger may use: 1, 3, or 1 and 3 (auto). |
| Car charger | Batteries help with the peak | `ev_batt_cover` | While the car charges. On: the batteries cover it down to the peak reserve. Off: the peak guard leaves the car out, so the car alone can set the peak. |
| Car charger | Mode after a restart | `ev_mode_start` | Keep the last mode, or start in Off. A restart never changes the charger's current. |
| Car charger | Mode after a restart | `ev_mode_start` | Keep the last mode, or start in Off. A restart in Solar sets the charger to 0 A first, other modes leave its current. |
| Car charger | Sun kept back (W) | `ev_margin_w` | Solar: this much spare sun is never given to the car. |
| Car charger | Start after (minutes) | `ev_start_min` | Solar: the car starts after this long with enough spare sun. |
| Car charger | Pause after (minutes) | `ev_pause_min` | Solar: with too little sun the car holds 6 A this long, then pauses. |
| Advanced | Start control on boot | `auto_start` | Off by default. Leave it off until the site is commissioned, so someone presses Start after each restart. |
| Advanced | Control gain | `gain` | How much of the remaining error control corrects each cycle. Measured on real hardware, do not raise it. |
| Advanced | Largest change per cycle (W) | `slew_w` | How far the command may move in one cycle. 0 follows “Inverter rating” and is recommended. |
@@ -3278,9 +3281,10 @@ it.
### Car charger
The add-on can drive your car charger and shows it on **Home**, on a *Car* card.
The card has two modes in this version: **Off** (the add-on only reads the
charger and writes nothing) and **Manual** (the add-on sets the current and the
phases you choose). Solar and Night modes come in later versions.
The card has three modes in this version: **Off** (the add-on only reads the
charger and writes nothing), **Manual** (the add-on sets the current and the
phases you choose) and **Solar** (the car charges only from spare sun). Night
mode comes in a later version.
| option | meaning |
|---|---|
@@ -3290,6 +3294,9 @@ phases you choose). Solar and Night modes come in later versions.
| `ev_phases` | `1`, `3` or `auto` (1 and 3). |
| `ev_batt_cover` | On (the default): the batteries help cover the car down to the peak reserve. Off: the car is left out of what the peak guard protects. |
| `ev_mode_start` | `keep` (the default) or `off`: the mode after a restart. |
| `ev_margin_w` | Solar: the spare sun never given to the car, 0 to 1000 W (100). |
| `ev_start_min` | Solar: minutes of enough sun before the car starts, 1 to 30 (2). |
| `ev_pause_min` | Solar: minutes the car holds 6 A on too little sun before it pauses, 1 to 30 (5). |
**What the Car card shows.** The state (Charging, Connected waiting, No car
connected, Car is full, Charger not reachable), the power and current, and the
@@ -3299,7 +3306,7 @@ no longer buy energy for a car that charged last night.
**Manual mode.** Choose *Manual* on Home, then set the current (6 A up to the
charger limit) and 1 or 3 phases. The same three are Home Assistant entities
when MQTT is on: `select.goodwe_car_mode` (Off, Manual), `number.goodwe_car_current`
when MQTT is on: `select.goodwe_car_mode` (Off, Manual, Solar), `number.goodwe_car_current`
and `select.goodwe_car_phases`. The mode, the current and the phases apply at
once, with no restart. The add-on writes each one once, when you change it, and
checks within 10 seconds that the charger took it.
@@ -3320,6 +3327,56 @@ checks within 10 seconds that the charger took it.
current again only if the charger shows a different one.
- Off writes nothing, ever.
**Solar mode.** Choose *Solar* on Home, or `Solar` in `select.goodwe_car_mode`.
The car charges only from the spare sun: what the solar panels make that the
house does not use (the meter, the batteries and the car's own power add up to
it). *Spare sun goes first to* (on the card, and `select.goodwe_car_sun_first`)
says who gets it first:
- **Batteries:** the car gets the sun the batteries cannot take. Each battery
that may charge from the sun (switched On, not refusing a charge, not full)
keeps its whole rating first. With your two batteries and one of them full,
7.9 kW of sun and 0.9 kW of house leave 1.9 kW for the car: 8 A on 1 phase.
- **Car:** the car takes the spare sun first, the batteries get the rest.
In both, `ev_margin_w` (100 W) is kept back. The current is the car's share
divided by 230 V per phase, rounded down, from 6 A up to the charger limit. It
changes at most once per 30 seconds and only by 1 A or more.
- **Start and pause.** The car starts after `ev_start_min` (2 minutes) with
enough sun for 7 A. Under 6 A worth it holds 6 A for `ev_pause_min` (5
minutes), from the batteries or the grid, then the charger goes to 0 A and
the card says *Waiting for sun*.
- **Phases** (`ev_phases` auto): Solar starts on 1 phase, goes to 3 at 4.5 kW for
3 minutes and back to 1 under 4.0 kW for 5 minutes, at most once per 10
minutes, always through the safe sequence above. With `ev_phases` 1 or 3 it
never switches. A car that draws one phase while three are allowed is counted
on one phase until it is unplugged.
- **When the sun cannot be measured** (the meter older than 15 seconds, a battery
or grid reading missing, readings late, a car reading that is stale or not
confirmed by the charger's energy meter), the current stands for
`ev_pause_min`, then 0 A.
- **The fail state is 0 A.** Choosing Off, stopping control, shadow mode, a
safety stop, a charger error, a stuck charger reading, unplugging the car and
stopping the add-on each set the charger to 0 A once. A 0 A the charger does
not take is tried again after a minute, three times, then an amber row says
so. After a restart, or when the charger or Home Assistant answers again,
Solar sets 0 A first and then starts by its own rules. At a stop of the
add-on the charger's 0 A goes out before the batteries go to 0 W, for at
most 15 seconds; if the charger does not take it, the notice *Car may still
be charging* follows.
- **Shadow mode** writes nothing but that one 0 A; a start in shadow mode writes
nothing at all. The card says what Solar would set.
- **Another writer.** If the charger shows a current Solar did not set for 30
seconds, Solar writes nothing over it (also no 0 A), shows an amber row and
logs one warning, until you press Solar again or the charger shows Solar's
value.
- **The peak limit** treats a Solar car exactly as a Manual car (below). Solar
does not slow the car for the peak in this version.
- **Energy.** The card says "{kWh} charged today, {kWh} from the sun", and the
sensor `goodwe_car_today_solar_kwh` has the sun's part. Only Solar's own
share of spare sun counts, not the hold's battery or grid power.
**The car is never slowed for the peak limit.** A Manual charge goes on whatever
the 15-minute peak does. With the default `ev_batt_cover` on, the batteries help
cover it down to the peak reserve; a 3-phase 16 A charge (11 kW) can empty two
@@ -3365,8 +3422,7 @@ charger* shows for an hour after a change. That is expected while you migrate.
current your helper held (`input_number.ev_manual_current`). Plug in and check
the current on the card and on the charger's display.
3. On the next sunny day, choose Solar, with *spare sun goes first to* set as
your priority switch was. (Solar comes in a later version; until then keep
Manual or Off.)
your priority switch was.
4. Keep your Home Assistant helpers for a week. To go back, set the add-on mode
to Off and switch the automation on. After that you can delete the helpers and
the automation.
@@ -3377,8 +3433,8 @@ off before you choose Manual, and the add-on off (mode Off) before you turn the
automation on.
**Home Assistant entities.** With MQTT the add-on adds the sensors
`goodwe_car_power`, `goodwe_car_state` and `goodwe_car_today_kwh`, and the three
controls named above. A saved ("retained") command is never applied, so a
`goodwe_car_power`, `goodwe_car_state`, `goodwe_car_today_kwh` and
`goodwe_car_today_solar_kwh`, and the four controls named above. A saved ("retained") command is never applied, so a
restart of Home Assistant cannot change the charger.
### Site
@@ -3514,7 +3570,14 @@ The car charge you set (Manual) takes the 15-minute period over the peak limit,
and the batteries cannot hold it because they are at the peak reserve or at
their full power. The add-on never slows the car, so this is information, not an
alarm. It is raised once per charging session. To stay under the limit, lower the
current.
current. In Solar it says "Solar charges the car at {a} A, which sets the
peak.": the same case, with the current the charger has.
### Car may still be charging
The add-on stopped in Solar mode, and the charger did not take the 0 A it sent
first. The batteries were set to 0 W on time anyway. Check the current at the
charger. At the next start Solar sets 0 A first and the notification goes.
### For installers: notifications