Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0862d87c8a | ||
|
|
37b85fffb5 | ||
|
|
550d2d3934 | ||
|
|
c79eb37392 | ||
|
|
45df1ac549 | ||
|
|
6412d00783 | ||
|
|
a33eb8ef1c | ||
|
|
68856bc3a0 | ||
|
|
5bff894cca | ||
|
|
4dc030929a | ||
|
|
0cfb99ed65 | ||
|
|
a60ebd3286 | ||
|
|
2768755400 | ||
|
|
6fbf2600f9 | ||
|
|
0ef8de26cb | ||
|
|
3083093e22 | ||
|
|
f62501174d | ||
|
|
49e010fdfb | ||
|
|
8d62abe36b |
@@ -2,10 +2,134 @@
|
||||
|
||||
### Not in a release yet
|
||||
|
||||
- **The car can now charge from spare sun (Solar mode).** Choose *Solar* on the Car card or in Home Assistant: the car gets only the sun the house does not use, after the batteries (or before them, your choice), and pauses when there is too little. Every way out of Solar, a stop and a restart set the charger to 0 A. Three new options, all with defaults: `ev_margin_w`, `ev_start_min`, `ev_pause_min`. See "Car charger" in DOCS ([[EV-20]]).
|
||||
- When the car charger does not take a current setting but is plainly working, you now see one amber row ("did not take the setting"), not a second "reading may be stuck" ([[EV-13]]).
|
||||
- The add-on no longer changes the car's phases while the car still draws: it waits until the charger reads under 100 W, and if the car is still drawing after 20 s it gives the current back and tries again after 10 minutes ([[EV-28]]).
|
||||
- When the add-on changes the car's phases while the batteries are at the peak reserve, there is no longer a false "Battery stopped limiting the peak" for a moment ([[EV-15]]).
|
||||
## 0.25.0
|
||||
|
||||
**A minor bump: the car can now charge from spare sun (Solar mode), and the Car card raises fewer false alarms. Three new options were added, all with defaults, and none needs setting.**
|
||||
Three options were added (`ev_margin_w`, `ev_start_min` and `ev_pause_min`), none was removed or renamed, and no default changed (95 options, 92 before). **Existing installs need no option change:** the new options have defaults, and `ev_charger` is still off, so an install that does not use the car charger runs as 0.24.0 did. It is a minor bump because it adds a feature and new options. Every saved setting still starts.
|
||||
|
||||
**The car can charge from spare sun (Solar mode).** Choose *Solar* on the Car card or in Home Assistant. The car gets only the sun the house does not use, after the batteries or before them (your choice), and pauses when there is too little. When the sun cannot be measured, for example when the meter goes silent, the current stands for 5 minutes (*Pause after*, `ev_pause_min`) and then goes to 0 A. Every way out of Solar, a stop and a restart set the charger to 0 A. See "Car charger" in DOCS ([[EV-20]], [[EV-51]]).
|
||||
|
||||
**Car charger fixes.** The add-on no longer changes the car's phases while the car still draws. Fewer false "Battery stopped limiting the peak" alarms while the car charges. A current the charger does not take shows one amber row, not two. The Car card's *Why* line says what the charger does and no longer switches between two wordings ([[EV-28]], [[EV-15]], [[EV-18]], [[EV-19]], [[EV-13]], [[EV-14]], [[EV-16]]). The fixes for [[EV-14]], [[EV-18]] and [[EV-19]] are shown in tests only: the test rig could not run them or could not show a difference. Watch the Car card and the notifications for a few nights.
|
||||
|
||||
**No change in behaviour:** the build checks now test against a newer copy of the shared test tools.
|
||||
|
||||
Contents of this release, in merge order since 0.24.0 (`f66048b`):
|
||||
|
||||
| | |
|
||||
|---|---|
|
||||
| `9fdce02` | When the add-on changes the car's phases while the batteries are at the peak reserve, there is no longer a false "Battery stopped limiting the peak" for a moment ([[EV-15]], #262) |
|
||||
| `43b0db7` | While the car explains why the house is over the peak limit, the alarm no longer fires at the start of a 15-minute period and stays red for the whole period ([[EV-18]], #264) |
|
||||
| `8150608` | No alarm for a moment when the batteries first reach the peak reserve early in a Manual car session ([[EV-19]], #265) |
|
||||
| `00b116e` | With *Batteries help with the peak* on, the Car card's *Why* line no longer switches between two wordings while the car is over the peak limit ([[EV-16]], #266) |
|
||||
| `4eba2d9` | The build checks test against a newer copy of the shared test tools. There is no change in behaviour ([[CI-20]], #267) |
|
||||
| `76f4de2` | The add-on no longer changes the car's phases while the car still draws. It waits until the charger reads under 100 W, and if the car still draws after 20 s it gives the current back and tries again after 10 minutes ([[EV-28]], #268) |
|
||||
| `c8f5292` | When the charger does not take a current setting but is plainly working, you see one amber row ("did not take the setting"), not a second "reading may be stuck" ([[EV-13]], #269) |
|
||||
| `885528a` | In shadow mode, and after a phase change was given up, the Car card's *Why* line says what the charger does, not what you set ([[EV-14]], #270) |
|
||||
| `cc8c0dc` | The car can charge from spare sun (Solar mode), with three new options: `ev_margin_w`, `ev_start_min` and `ev_pause_min` ([[EV-20]], #271) |
|
||||
| `09b6af9` | Solar mode: no false "charger reading may be stuck" after the add-on's own write, no back and forth between two currents, and the waits count from when the sun drops ([[EV-20]], #272) |
|
||||
| `2768755` | The build checks test against a newer copy of the shared test tools. There is no change in behaviour (#273) |
|
||||
| `5bff894` | Solar mode: one failed charger reading no longer pauses the car in full sun ([[EV-20]], #274) |
|
||||
| `c79eb37` | Solar mode: when the meter goes silent, the car goes to 0 A at the first check once the meter reading is 330 s old ([[EV-51]], #275) |
|
||||
|
||||
|
||||
### Known issues
|
||||
|
||||
- A false "Battery is not keeping up" can still show when the peak guard pauses a maintenance charge ([[SAFETY-92]]).
|
||||
- A battery capped at a low limit with a perfectly flat reading can still trip the stale check ([[SAFETY-74]]).
|
||||
- A battery whose reading at rest is beyond about ±175 W is still not caught when it refuses ([[SAFETY-97]]).
|
||||
- The peak guard can still back off near the end of a 15-minute period when a meter reading is late, by less than 30 s. This is about the guard's discharge only; a grid charge is cut back since 0.19.2 ([[SAFETY-99]]).
|
||||
- Two inverters: the maintenance charge can switch on and off while the house is above the peak aim ([[SAFETY-88]]).
|
||||
- Two inverters: the "circulating" figure counts a battery's reading at rest ([[SAFETY-98]]).
|
||||
- Two inverters: a drain that starts during a big step in house use can send the other battery to full power, and about 1 kW goes to the grid for about 10 s ([[SAFETY-104]]).
|
||||
- Two inverters: when a battery comes back during a maintenance charge, the grid can step by several kW at once ([[SAFETY-101]]).
|
||||
- Two inverters: when a battery drops out during a solar surplus, the others can swing by up to 1.5 kW in a simulation ([[SAFETY-105]]).
|
||||
- Two inverters: after a drain ends, a change in house use can go unanswered for about 9 s, because some readings are old ([[SAFETY-106]]).
|
||||
- Two inverters: when one battery's level is missing, both batteries are held at 0 W, and for about 15 s the last command stays on ([[SAFETY-108]]).
|
||||
- Two inverters: if one battery's level stays missing for 12 h, the other battery's cycle can be marked failed, with a 7-day wait and a notice, though it is healthy. This comes from reading the code; it has not been seen on a site ([[MAINT-17]]).
|
||||
- When the 15-minute demand forecast sensor counts the battery's own charge, the maintenance charge runs at about half the power the peak limit leaves, so it takes about twice as long (seen on a site: about 1.2 kW instead of 2.5 kW; the peak limit was kept). At the start of a month, before a peak above the limit, that is about 2 kWh a night in a rig test: the cycle can reach its 36 h limit after about 4 nights and fail, and since 0.22.0 the other battery gets no grid charge on those nights ([[SAFETY-111]]).
|
||||
- One inverter: after a link drop, the battery's own safety stop to 0 W can be taken as a refusal, and the site stays at 0 W for up to 15 min ([[SAFETY-102]]).
|
||||
- After a Home Assistant restart, control still waits until Home Assistant has finished starting, which can take several minutes, though the readings are already there ([[SAFETY-115]]).
|
||||
- While Home Assistant is not answering, the page can list inverters as refusing commands and sensors as missing, and send you to Developer Tools, though they are fine ([[UX-37]]).
|
||||
- If Home Assistant hangs or stops, the page keeps saying "Waiting for Home Assistant" and never turns into an alarm ([[SAFETY-113]]).
|
||||
- Right after Home Assistant has started, the page can say for about 4 s that an inverter cannot be controlled, and the first command can come late ([[SAFETY-114]]).
|
||||
- After a Home Assistant restart, the controller status sensor can still say "running" while the add-on cannot control. It was seen once, and the cause is not known ([[SAFETY-116]]).
|
||||
- Battery modes on: after a planned top-up from the grid, the Batteries screen can say "Enough sun is forecast" ([[UX-32]]).
|
||||
- Battery modes on: the forecast line "we count on" can show more sun than the plan counts, because the plan takes house use off first ([[UX-33]]).
|
||||
- Battery modes on: before a planned top-up, the Today list shows a smaller "gives" amount than the plan will use; it grows as the charge happens ([[UX-34]]).
|
||||
- Two inverters, battery modes on: while the other battery is in its maintenance charge, a battery's card can say it charges from the grid while it stays at 0 W ([[OPT-18]]).
|
||||
- Two inverters, battery modes on: while a battery refuses to charge in a cheap run, the action log on the page gets about 8 lines an hour for its retries, and the page hint says "waiting for a better price" ([[UX-38]]).
|
||||
- A battery in a safety stop, or one the add-on cannot reach, can still be started for a cycle, and its drain then waits about 12 h and ends in a failed-cycle notice. This comes from reading the code; it has not been seen on a site ([[MAINT-19]]).
|
||||
- On the Settings page, the rows of the solar forecast lists are labelled "Phase 1", "Phase 2" instead of "Sensor 1", "Sensor 2" ([[UX-27]]).
|
||||
- In the solar forecast list, a blank or repeated row makes "source 2 of 2" count differently from the rows on the Settings page ([[UX-28]]).
|
||||
- The solar forecast message says "has no reading" also when the sensor shows a number that is too old or in the wrong unit ([[UX-29]]).
|
||||
- If you use only the forecast lists, two Settings notes sit on the single-sensor field, and one of them tells you to set that field ([[UX-30]]).
|
||||
- After a restart during a price outage, the "No prices" message can say "yet" when prices did come in earlier ([[UX-39]]).
|
||||
- On the new settings page, you cannot see whether a price service token is set. Check the Configuration tab ([[UX-41]]).
|
||||
- On the classic settings page, the first click on Save after editing a field can do nothing. Click again ([[UX-42]]).
|
||||
- A steady overload on a 1 s meter can warn, and send the Home Assistant notification, 2 or 3 times at the start of each 15-minute period instead of once. The peak limit is still kept ([[SAFETY-122]]).
|
||||
- A fixed tariff is priced once per hour, so a price window that starts or ends at :15, :30 or :45 gets the wrong price for part of that hour. Windows that start and end on the hour are right ([[TARIFF-23]]).
|
||||
- Step 6 of the setup wizard stays empty because of an error in the page, in English and in Dutch ([[UX-51]]).
|
||||
- On Dutch pages, refusal texts, the last-event line under the Home buttons, the installer details and the trading status sentences are still English, and a few Dutch texts read badly, such as "1 metingen geweigerd" ([[UX-52]]).
|
||||
- Some price texts say "hour" where the add-on acts on a 15-minute period, such as "cheapest hour" ([[UX-47]]).
|
||||
- After the add-on restarts, the Home price chart shows no price for the earlier part of today, and the setup check can say "12 of 24 hours", though the prices are known ([[UX-48]]).
|
||||
- With battery modes on and only batteries on "Leftover solar", the Home price chart can mark a cheap period where no battery charges ([[UX-49]]).
|
||||
- On a phone, the bars of the Home price chart are too thin to tap one 15-minute period. The arrow keys work ([[UX-50]]).
|
||||
- In the last second of a 15-minute period, being a few watts over the aim can make the peak guard ask a battery for full power for one second. When a charge ends on a period edge, the last-second give can fade out over about 10 s, and a rig test exported up to 7.4 kW for about 8 s ([[SAFETY-124]]).
|
||||
- During the night grid charge, a 15-minute period can end 6 to 14 W over the peak aim, because the battery charges harder than asked. This was seen in simulation; a rig test saw 2 to 8 W ([[OPT-35]]).
|
||||
- The test rig could not bring back the false peak alarm that [[SAFETY-126]] fixes, so that fix is shown in simulation only. Watch the notifications for a few nights ([[TEST-35]]).
|
||||
- The night cheap run is sized for the batteries' full charging power, not for what the peak limit leaves. Under a tight limit the run can end before the batteries reach their level, and Home can show a level they do not reach (79.9 % against a shown 95 % in a rig test) ([[OPT-25]]).
|
||||
- By day, a Leftover solar plan that has only a daily forecast figure counts the sun from now, not from when the figure was read. It counts about 22 % too much for a figure one hour old; the night plan is not affected ([[OPT-30]]).
|
||||
- The night charge can buy too much in a house that uses more at night than by day, such as one with a heat pump or a car charger that is not set up in the add-on, and on a sunny day, because spare sun in one expensive hour does not count for the later ones ([[OPT-31]]).
|
||||
- A cheap run that has already started can overlap a new give run after a re-plan, so a battery can charge from the grid at the dearest price for part of an hour. This was seen in a test case, not on a site. Also in 0.19.2 ([[OPT-32]]).
|
||||
- If the solar forecast sensors stop updating before 17:00, as in winter or further north, there is no forecast from three hours after their last update until 20:00 ([[OPT-33]]).
|
||||
- With a forecast that gives only a daily total, the sun is spread an hour off on the two clock-change days after the change. The day's total is right ([[OPT-24]]).
|
||||
- The add-on learns the house's use only once a solar forecast is set, so a site that adds a forecast later waits one more day for its first plan ([[OPT-26]]).
|
||||
- Home says "No trading on price yet: no prices have arrived" when every battery is on Solar first, though the prices are shown ([[UX-55]]).
|
||||
- The Home plan header can say "Charges in the cheapest hour, gives power in the dearest" when Home draws no charge, and it says "hour" for 15-minute prices ([[UX-56]]).
|
||||
- While the peak guard holds back charging, Home hides the rest of the cheap run and gives no reason. The charge starts again when the guard lets go ([[UX-57]]).
|
||||
- With battery modes on and selling on, Home can draw a "Sells up to" block when the add-on judges the trade not worth it, and then it will not sell ([[UX-58]]).
|
||||
- Home, the plan and the Forecast tab stop drawing a battery's give at the trading floor, though control goes on giving down to the battery's cut-out ([[UX-59]]).
|
||||
- During a price outage, the Batteries screen says "Prices differ too little" and Home says "The price gap is too small" ([[UX-60]]).
|
||||
- With battery modes on and no meter, or a meter that is a Home Assistant entity, a grid charge is not possible and nothing says so ([[UX-61]]).
|
||||
- On the Batteries screen, a charge the add-on refused in a cheap run reads as "Saves its power for ...", for up to 15 minutes ([[UX-62]]).
|
||||
- A Leftover solar battery with no capacity set never charges from the grid when a solar forecast is set, and nothing warns about it ([[UX-63]]).
|
||||
- The "How the modes work" box on the Batteries screen does not describe Cheap hours only ([[UX-64]]).
|
||||
- With battery modes on, Settings still shows "Trade on the price spread", which the modes ignore. A site with modes on and no price source starts, and the Batteries screen says "No prices, so it follows the house" without pointing to Settings ([[UX-65]]).
|
||||
- With battery modes off and several equal prices in a row, Home and the Forecast tab draw one price quarter, while the add-on trades every quarter of the run ([[UX-67]]).
|
||||
- Late in the day, the Forecast tab's "now" line and last bars sit over the axis labels at the right edge ([[UX-68]]).
|
||||
- The Forecast tab's level curve charges at each battery's full rating. Under a peak limit the levels it draws are too high and a charge block can end early (54.6 % shown against 39.7 % in a rig test) ([[UX-70]]).
|
||||
- The peak forecast check says maintenance charging is not kept under the peak limit when no peak forecast is set, but since 0.19.2 it is ([[UX-73]]).
|
||||
- The peak guard row can show the same figure twice, such as "at this rate 3 500 W, over 3 500 W". Also in 0.19.2 ([[UX-74]]).
|
||||
- If the inverter's setpoint entity appears in Home Assistant after the add-on has started, the page keeps saying "Inverter control: not found in Home Assistant" and the batteries say "An alarm stopped control" until a restart, though control runs ([[UX-75]]).
|
||||
- In the last minute of a 15-minute period, with Home Assistant readings 30 s late, the period can end about 80 W over the peak aim and over the limit: 3 530 W against a 3 450 W aim and a 3 500 W limit in a rig test with a 2 kW load added 45 s before the end. The peak guard sees the load too late to hold it back ([[SAFETY-133]]).
|
||||
- With Home Assistant readings 10 s late, the grid charge in a cheap run can swing by several kW. In a test the add-on asked for an 8.7 kW charge (9.6 kW on 0.20.0) ([[SAFETY-132]]).
|
||||
- A plan rebuilt while the battery levels are missing for a moment can drop a cheap run that has not started yet, so the battery does not charge that day. Seen in a replay of real prices, where it cost about EUR 0.40 of extra grid use; the Leftover solar change in 0.20.1 no longer triggers it in those replays, but the cause stays ([[OPT-37]]).
|
||||
- On a 5 s meter, Home Assistant readings 10 s late are still not caught, and readings 15 s late only after about 4 minutes. Control now follows the meter more gently, so less goes to the grid: in a simulation with a changing load, 340 Wh became 189 Wh at 10 s late and 363 Wh became 296 Wh at 15 s late. In a rig test, 15 s late exported 13 to 19 % more than before ([[SAFETY-136]], [[SAFETY-134]]).
|
||||
- With readings 10 to 15 s late, the hold can end in the middle of the delay and the swing can come back. Seen in rig tests with a 2 s and a 5 s meter ([[SAFETY-134]]).
|
||||
- With readings 10 s late on a 1 s meter, the grid can still move between -422 and +340 W while the batteries are held. With a very long delay (30 to 90 s) the request can swing by about 900 W every few seconds. Seen in review tests ([[SAFETY-130]]).
|
||||
- A battery that answers very slowly (10 s or more) can be taken for late Home Assistant readings and held, and the page then blames Home Assistant. A GoodWe battery settles in about 6 s and this has not been seen on one ([[SAFETY-131]]).
|
||||
- The page row for late readings reads awkwardly in English ("Home Assistant readings show requests about N seconds late, so control holds the batteries"), and the Dutch text misses a word ([[UX-78]]).
|
||||
- When the add-on stops, a write that takes more than 2 s can still land after the 0 W, and the 30 s safety timer on the ESPHome board then sets 0 W. After the Stop button, a cycle that had already decided can send its share (560 to 670 W) just after the 0 W; the next cycle sends 0 W again ([[SAFETY-138]]).
|
||||
- In the last hour of a cheap run, Home can draw a battery's grid charge up to an hour past the time control stops charging it. It only draws too much, never too little ([[UX-79]]).
|
||||
- A tomorrow solar forecast sensor that reports just after midnight with yesterday's value can be used as the new day's forecast for up to 12 hours. This has not been seen on a site ([[OPT-39]]).
|
||||
- During a cheap-hours charge, at some 15-minute boundaries the add-on sends 0 W for one tick ("no trade (headroom)") and then goes on. Seen in a rig test, in 5 of 8 cases; once, with a frozen battery reading, it left a battery at 0 W until 23:45 ([[OPT-40]]).
|
||||
- While one battery's monthly cycle charges, the other battery's card on Home says "Saves its power for higher prices", and the plan still shows its grid charge in the cheap hours, though it will not charge ([[UX-80]]).
|
||||
- After a failed monthly cycle, the plan line shows the day the wait ends, such as 18 November, not when the cycle tries again, such as 19 November at 19:00 ([[MAINT-26]]).
|
||||
- At the start of a cheap window the peak guard can step once although the period is under the aim, and the step can land on a battery in its monthly charge. In a rig test it gave 1.7 to 2.3 kW for 6 s ([[SAFETY-140]]).
|
||||
- A grid charge at full power in the last seconds of a 15-minute period can run into the next period, where the peak guard cuts it back ([[SAFETY-139]]).
|
||||
- In a long real peak, the peak guard can end a 15-minute period up to 10 W over its aim, as 0.22.0 does (up to 31 W there). In a rig test the month's highest peak did not rise ([[SAFETY-141]]).
|
||||
- The peak reserve notification can be created again and again, 24 to 47 times in 2 hours in a rig test, while the guard holds a battery at its reserve. 0.22.0 does the same ([[MAINT-29]]).
|
||||
- When you switch the car charger off, its three sensors stay in Home Assistant with their last values. From reading the code, the PV power sensor does the same when it is switched off ([[TEL-19]]).
|
||||
- In Settings, the choice for no car charger says "None", while its help says "Off" ([[UX-81]]).
|
||||
- DOCS names the car's energy sensor `goodwe_car_today_kwh`, but Home Assistant creates it as `sensor.goodwe_car_energy_today` ([[TEL-20]]).
|
||||
- While the car charges in Manual mode, a false "Battery stopped limiting the peak" can still show in the first minutes of a 15-minute period, though the period is heading under the limit. Seen in rig tests, also on builds before this one ([[SAFETY-143]]).
|
||||
|
||||
### If you are crossing from a version older than 0.10.0
|
||||
|
||||
`## 0.10.0` below can refuse an old config: `slew_w` above its limit, and the
|
||||
withdrawn `price_provider` ids `engie_dynamic`, `totalenergies_dynamic` and
|
||||
`eneco_eddy`. Read it before you update. Run `tools/predeploy_check.py` with the
|
||||
bare options (`jq '.data.options'`) first.
|
||||
|
||||
## 0.24.0
|
||||
|
||||
|
||||
@@ -144,3 +144,59 @@ one small set of facts and derives every path from them:
|
||||
`meter_max_age_s` is the bound (a silent meter: 0 A at
|
||||
`meter_max_age_s` + `ev_pause_min`).
|
||||
|
||||
## Rig round 2 (rig FAIL on 09b6af9), PM rulings
|
||||
|
||||
- **A short charger read gap** (chargers.py `CarTracker.observe`, shared by
|
||||
Solar, Manual and the peak guard): a reading missing for less than
|
||||
`stale_input_s` keeps the last trusted reading (`held`). A gap is a read
|
||||
that got no answer, or every required entity unavailable; one entity
|
||||
missing, a wrong power unit or the login off stay readings of their own
|
||||
(EV-03 round 4, unchanged); nothing is decided
|
||||
or written in that cycle: no writer steps (`ctl_car.car_step` returns), no
|
||||
plan count moves (start, phase change, hold, `set_at`) and a decision due
|
||||
then runs on the next real reading (review r3, PM design). The one
|
||||
exception is Solar's pause by the meter's age (C18, `held_pause`). A held
|
||||
read neither arms nor clears the stuck check. At `stale_input_s` the
|
||||
missing reading is taken as before (the safe path: the charger is gone, 0 A first on its return).
|
||||
This also ends the false PEAK_GUARD_FLOOR_LIMITED after one gap (EV-18
|
||||
T10(b) changed accordingly).
|
||||
- **Silent meter on `ha_signed`:** Solar's unknown-sun pause is timed from the
|
||||
meter's age: unknown since the age passed `meter_max_age_s`, so 0 A on the
|
||||
first car step whose own meter age (now minus the last reading, at that
|
||||
step) is >= `meter_max_age_s` + `ev_pause_min` (330 s), held steps included.
|
||||
Arrival sources are unchanged.
|
||||
- **EV-51: decided at the step's own meter age.** Every decision that rests on
|
||||
the meter's AGE is taken at the writer step's own age, not at the age the
|
||||
cycle saw one step earlier: the pause above, the write block while the meter
|
||||
is silent (no non-zero current, C17), the held-read pause (C18) and the
|
||||
late-readings hold with its stale rule (a spare read while the hold was on
|
||||
is not used once the step's own late time reaches `stale_input_s`). The
|
||||
meter's VALUES (spare, target) stay the cycle's, one cycle of sensor latency
|
||||
being normal, but only while the step's own age says the meter is fresh:
|
||||
once it is past `meter_max_age_s` the spare is unknown, so nothing starts or
|
||||
rises from it (C23). `car.held` and `car.reading` are unchanged. Arrival
|
||||
sources keep the cycle's age for their "spare unknown" check. At log level
|
||||
debug each Solar step logs one line: time, the meter age at the step, the
|
||||
decision and the write. The decision is one word: `steady`, `start`,
|
||||
`raise`, `lower`, `pause`, `hold` (the late-readings hold), `wait-unknown`
|
||||
(the spare is unknown and the pause timer counts) or `wait-held` (a held
|
||||
charger read).
|
||||
- **No non-zero write while the meter is silent (SPIKE-06 C17, N8 strict):**
|
||||
while the meter's age is past `meter_max_age_s`, Solar sends no non-zero
|
||||
current: no retry, no raise, no phase change begun, and a phase change
|
||||
under way ends at its 0 A (no select after that, no closing current); the
|
||||
plan pauses. 0 A is always allowed. Also on a held read (`nz_block`).
|
||||
- **The age pause on a held read (C18):** on a held cycle Solar does not step
|
||||
(review r3, PM design); only `held_pause` runs: while the meter is silent
|
||||
and its age has reached `meter_max_age_s` + `ev_pause_min`, the plan pauses
|
||||
and a NEW 0 A goes out (no retry to a charger that is not answering). No
|
||||
phase change, start, hold pause or other count moves on a held cycle.
|
||||
- **Accepted (PM, P9g):** a frozen charger that also stops answering is
|
||||
flagged only once it answers again; the 15 s safe path covers the gap.
|
||||
- **A held read during a phase change (SPIKE-06 C19):** a phase change under
|
||||
way does nothing on a held read (no write, no pause) and goes on at the next
|
||||
real reading; it ends at its 0 A only while the meter is silent (C17). No
|
||||
phase change begins on a held cycle; a gap of `stale_input_s` or more takes
|
||||
the safe path unchanged. Accepted by design (PM): a one-sample partial
|
||||
reading (only power unavailable, say) still gives the D2 0 A.
|
||||
|
||||
|
||||
@@ -498,8 +498,20 @@ class SunInputs:
|
||||
|
||||
def __init__(self, target_w=None, hold=False, auto=True, start_s=120.0,
|
||||
pause_s=300.0, spare_w=None, room_w=0.0, margin_w=100.0,
|
||||
first=DEFAULT_FIRST):
|
||||
first=DEFAULT_FIRST, unknown_s=0.0, silent=False,
|
||||
meter_back=False, age_s=None):
|
||||
self.target_w, self.hold, self.auto = target_w, hold, auto
|
||||
# EV-51: the meter's own age at the writer step (None: no reading), and
|
||||
# `meter_back`: the cycle's snapshot said "meter too old" but the step's
|
||||
# own age says a new reading came, so no unknown timer is carried over.
|
||||
self.meter_back, self.age_s = meter_back, age_s
|
||||
# EV-20 rig round 2: how long the sun has already been unknown when
|
||||
# the cause is the meter's own age (`ha_signed`): the pause is timed
|
||||
# from that age, not from the cycle that noticed it.
|
||||
self.unknown_s = unknown_s
|
||||
# EV-20 SPIKE-06 C17 (N8): the meter is known silent (its age past
|
||||
# `meter_max_age_s`): no non-zero current goes out, only 0 A.
|
||||
self.silent = silent
|
||||
self.start_s, self.pause_s = start_s, pause_s
|
||||
self.spare_w, self.room_w, self.margin_w = spare_w, room_w, margin_w
|
||||
self.first = first
|
||||
@@ -563,11 +575,15 @@ class SolarPlan:
|
||||
self.switch, self._before = False, None
|
||||
|
||||
def step(self, now, *, target_w, n_now, auto, clamp, start_s, pause_s,
|
||||
hold=False, gap_ok=True):
|
||||
hold=False, gap_ok=True, unknown_s=0.0, meter_back=False):
|
||||
"""`n_now`: the phases the car draws on now (1 for a one-phase car);
|
||||
`auto`: Solar may choose the phases; `gap_ok`: a phase change is
|
||||
allowed now (EV-04's one per `PHASE_GAP_S`); `hold`: readings late
|
||||
under the stale bound, everything stands."""
|
||||
under the stale bound, everything stands. `meter_back` (EV-51): the
|
||||
meter's own age is fresh again at this step: the unknown timer that
|
||||
counted its silence starts over."""
|
||||
if meter_back:
|
||||
self.unknown_since = None
|
||||
if hold:
|
||||
# Readings late under the stale bound: nothing changes, but a
|
||||
# hold or an unknown spare that has run its time still pauses
|
||||
@@ -586,6 +602,11 @@ class SolarPlan:
|
||||
if self.a > 0.0:
|
||||
if self.unknown_since is None:
|
||||
self.unknown_since = now
|
||||
if unknown_s > 0.0:
|
||||
# ha_signed: unknown since the meter's age passed its
|
||||
# bound, so the pause comes at that age + `pause_s`.
|
||||
self.unknown_since = min(self.unknown_since,
|
||||
now - unknown_s)
|
||||
# A hold that began on a known low spare still ends on time.
|
||||
if now - self.unknown_since >= pause_s or (
|
||||
self.low_since is not None
|
||||
@@ -721,6 +742,8 @@ class SolarWriter(ManualWriter):
|
||||
self.stuck_starts = 0 # SPIKE-06 C12: starts under one stuck verdict
|
||||
self.stuck_wait = None # ... used up: the next start not before
|
||||
self.stuck_warned = False # ... and its one CHARGER_REFUSED was given
|
||||
self.nz_block = False # C17/C18: this step writes 0 A at most
|
||||
self.held_step = False # C18: a held read: only a NEW 0 A goes out
|
||||
|
||||
def owe_start(self) -> None:
|
||||
"""C1: the add-on starts in Off while an exit 0 A of its own was still
|
||||
@@ -828,7 +851,11 @@ class SolarWriter(ManualWriter):
|
||||
`MAX_TRIES` and never waits (0 A is the safe side)."""
|
||||
if self.hold:
|
||||
return
|
||||
if want > TOL_A and self.nz_block:
|
||||
return # C17/C18: 0 A only, no retry or raise
|
||||
if self.sent_a is not None and abs(self.sent_a - want) <= TOL_A:
|
||||
if self.held_step:
|
||||
return # C18: no retry to a charger not answering
|
||||
if self.taken or self.gave_up or (
|
||||
self.fail_at is not None
|
||||
and now - self.fail_at < RETRY_S):
|
||||
@@ -919,7 +946,8 @@ class SolarWriter(ManualWriter):
|
||||
now, target_w=sun.target_w, hold=sun.hold, n_now=n_now,
|
||||
auto=sun.auto and not self.single and not self.phases_gave_up,
|
||||
clamp=clamp, start_s=sun.start_s, pause_s=sun.pause_s,
|
||||
gap_ok=gap_ok)
|
||||
gap_ok=gap_ok, unknown_s=getattr(sun, "unknown_s", 0.0),
|
||||
meter_back=getattr(sun, "meter_back", False))
|
||||
|
||||
@staticmethod
|
||||
def _drawing(r) -> bool:
|
||||
@@ -975,12 +1003,41 @@ class SolarWriter(ManualWriter):
|
||||
"prev": None, "from": r.phases_allowed}
|
||||
|
||||
# ------------------------------------------------------------- step
|
||||
async def held_pause(self, drv, r, *, sun, now, tracker) -> None:
|
||||
"""EV-20 (C18, PM design r3): on a held charger read only the pause by
|
||||
the meter's age may come (0 A): nothing else in the plan moves, no
|
||||
phase change begins or goes on, no retry. Called instead of `step`."""
|
||||
if not self.engaged or self.seq is not None or self.hold \
|
||||
or self.fault is not None or self.restart \
|
||||
or self.plan.a <= 0.0 or self.plan.switch:
|
||||
return
|
||||
if not getattr(sun, "silent", False) \
|
||||
or getattr(sun, "unknown_s", 0.0) < sun.pause_s:
|
||||
return
|
||||
self.nz_block = self.held_step = True
|
||||
try:
|
||||
self.plan.pause("unknown")
|
||||
cur = None if r is None else (
|
||||
r.allowed_a if r.allowed_a is not None else r.setpoint_a)
|
||||
await self._put(drv, 0.0, cur, now, tracker)
|
||||
finally:
|
||||
self.nz_block = self.held_step = False
|
||||
|
||||
async def step(self, drv, r, *, mode, sun, clamp, now, tracker, writing,
|
||||
status, clock=None):
|
||||
status, clock=None, held=False):
|
||||
"""One cycle. `sun` is `SunInputs` (None outside Solar); `writing` is
|
||||
False in shadow mode, while control is stopped, under a safety stop
|
||||
and while stopping."""
|
||||
and while stopping. `held`: the charger missed this read and the last
|
||||
reading stands in (EV-20 round 2): the step may pause, never raise.
|
||||
`ctl_car.car_step` no longer passes it (review r3): on a held cycle
|
||||
only `held_pause` runs."""
|
||||
self._clock = clock or (lambda: now)
|
||||
# SPIKE-06 C17/C18: while the meter is silent, or on a held read, no
|
||||
# non-zero current goes out (no retry, no raise, no closing current
|
||||
# of a phase change); 0 A always may.
|
||||
self.nz_block = bool(held or (sun is not None
|
||||
and getattr(sun, "silent", False)))
|
||||
self.held_step = bool(held)
|
||||
entering = mode == SOLAR and self.mode_was != SOLAR
|
||||
self.mode_was = mode
|
||||
if entering:
|
||||
@@ -1121,6 +1178,20 @@ class SolarWriter(ManualWriter):
|
||||
gap = self._gap_ok(now)
|
||||
if self.sent_a == 0.0 and not self.taken:
|
||||
self.plan.ok_since = None # 0 A first, then the start rule
|
||||
if self.seq is not None and self.held_step:
|
||||
# SPIKE-06 C19: a held read decides nothing for a phase change
|
||||
# under way (no write, no pause); it goes on at the next real
|
||||
# reading. A gap that reaches `stale_input_s` takes the safe path.
|
||||
return
|
||||
if self.seq is not None and self.nz_block:
|
||||
# C17: a phase change under way ends at its 0 A; no select and no
|
||||
# closing current while the meter is silent. The plan pauses and
|
||||
# starts again by the start rule.
|
||||
self.seq = None
|
||||
self.plan.end_switch(False)
|
||||
self.plan.pause("unknown")
|
||||
await self._put(drv, 0.0, cur, now, tracker)
|
||||
return
|
||||
if self.seq is not None:
|
||||
self._plan_step(sun, now, clamp, self.plan.n, gap)
|
||||
if self.plan.a < CH.MIN_A:
|
||||
@@ -1163,7 +1234,7 @@ class SolarWriter(ManualWriter):
|
||||
return
|
||||
self._plan_step(sun, now, clamp, n_now, gap)
|
||||
want = self.amps_out(clamp)
|
||||
if want >= CH.MIN_A and self.plan.switch \
|
||||
if want >= CH.MIN_A and self.plan.switch and not self.nz_block \
|
||||
and self.plan.n != n_now and not self.single:
|
||||
if self.gave_up or (self.fail_at is not None
|
||||
and now - self.fail_at < RETRY_S):
|
||||
|
||||
@@ -255,6 +255,18 @@ def display_class(text) -> str | None:
|
||||
return None
|
||||
|
||||
|
||||
def _is_gap(why) -> bool:
|
||||
"""EV-20: does this unavailable reading's cause mean "no answer" (a read
|
||||
gap), not a reading the charger gave?"""
|
||||
why = why or ""
|
||||
if why == "no answer":
|
||||
return True
|
||||
if why.startswith("no answer from "):
|
||||
gone = {x.strip() for x in why[len("no answer from "):].split(",")}
|
||||
return set(REQUIRED) <= gone
|
||||
return False
|
||||
|
||||
|
||||
def reading_from_states(states: dict) -> ChargerReading:
|
||||
"""A `ChargerReading` from `{role: state object or None}`. Pure."""
|
||||
def txt(role):
|
||||
@@ -719,6 +731,7 @@ class CarTracker:
|
||||
# write went out, kept at `begin_write` (the arming baseline). Empty: no
|
||||
# write begun, and `note_write` uses `sig`.
|
||||
pre_sig: tuple = ()
|
||||
held: bool = False # EV-20: the last reading stands in for a gap
|
||||
armed_at: float | None = None
|
||||
armed_sig: tuple | None = None
|
||||
sig: tuple | None = None
|
||||
@@ -735,6 +748,17 @@ class CarTracker:
|
||||
persist: bool = False # set when `today` changed, for the store
|
||||
|
||||
def observe(self, r: ChargerReading, now: float, now_utc, day: str):
|
||||
if not r.available and self.bad_since is None:
|
||||
self.bad_since, self.bad_since_utc = now, now_utc
|
||||
if self._held(r, now):
|
||||
# EV-20 rig round 2 (PM): a reading missing for less than
|
||||
# `stale_s` keeps the last trusted figure and decides nothing:
|
||||
# no write, no pause, and it neither arms nor clears the stuck
|
||||
# check. At `stale_s` the missing reading is taken as before.
|
||||
self.held = True
|
||||
self._status_edge(now, now_utc)
|
||||
return
|
||||
self.held = False
|
||||
self.reading = r
|
||||
self.obs_at = now
|
||||
self._corr_note(r, now)
|
||||
@@ -757,6 +781,16 @@ class CarTracker:
|
||||
self._timers(r, now)
|
||||
self._status_edge(now, now_utc)
|
||||
|
||||
def _held(self, r, now: float) -> bool:
|
||||
"""Is this missing reading a short gap behind a usable one? A gap is
|
||||
a read that failed (no answer at all) or Home Assistant showing every
|
||||
required entity unavailable. One entity missing, a wrong unit or the
|
||||
login off are readings of their own (EV-03), never held."""
|
||||
last = self.reading
|
||||
return (not r.available and _is_gap(r.why) and last is not None
|
||||
and last.available and self.last_ok is not None
|
||||
and now - self.last_ok < self.stale_s)
|
||||
|
||||
# -- reachability ----------------------------------------------------------
|
||||
def unreachable(self, now: float) -> bool:
|
||||
return self.bad_since is not None and now - self.bad_since >= UNREACHABLE_S
|
||||
|
||||
@@ -10,6 +10,7 @@ the guard treats a Solar car exactly as a Manual car).
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
import copy
|
||||
import dataclasses
|
||||
import logging
|
||||
from datetime import timezone
|
||||
@@ -83,6 +84,7 @@ class CarMixin:
|
||||
self.car_first = first if first in carmode.FIRSTS \
|
||||
else carmode.DEFAULT_FIRST
|
||||
self._car_late_s = None # EV-20: the cycle's late verdict
|
||||
self._car_late_mono = None # ... and the time it was read (EV-51)
|
||||
self._car_sun_now = None # ... and Solar's inputs of that cycle
|
||||
sun = data.get(CAR_SUN_KEY)
|
||||
self.car_sun = {"day": None, "kwh": 0.0}
|
||||
@@ -368,8 +370,93 @@ class CarMixin:
|
||||
cycle's read did) and writes only through `carmode`'s writers."""
|
||||
if not self.charger.configured():
|
||||
return
|
||||
held = bool(self.car.held)
|
||||
now = self.car_now()
|
||||
if self.car_mode != carmode.SOLAR:
|
||||
sun = None
|
||||
if self.car_mode == carmode.SOLAR:
|
||||
sun = self.car_sun_own(getattr(self, "_car_sun_now", None)
|
||||
or self.car_sun_inputs(now), now)
|
||||
w0 = self.car_solar
|
||||
a0, n_log = w0.plan.a, len(w0.log)
|
||||
await self._car_step_run(held, now, sun)
|
||||
if sun is not None and _LOG.isEnabledFor(logging.DEBUG):
|
||||
self._car_step_debug(held, now, sun, a0, n_log)
|
||||
|
||||
def _car_step_debug(self, held, now, sun, a0, n_log) -> None:
|
||||
"""EV-51: one DEBUG line per Solar writer step: the time, the meter's
|
||||
age at the step, what was decided and what was written. The decision
|
||||
is one word: steady, start, raise, lower, pause, hold (the
|
||||
late-readings hold), wait-unknown (the spare is unknown and the pause
|
||||
timer counts) or wait-held (a held charger read). Nothing at info and
|
||||
above; no secrets in it."""
|
||||
w = self.car_solar
|
||||
a1 = w.plan.a
|
||||
if a0 > 0.0 and a1 <= 0.0:
|
||||
what = "pause"
|
||||
elif held:
|
||||
what = "wait-held"
|
||||
elif sun.hold:
|
||||
what = "hold"
|
||||
elif a0 <= 0.0 and a1 > 0.0:
|
||||
what = "start"
|
||||
elif a1 > a0 + carmode.TOL_A:
|
||||
what = "raise"
|
||||
elif a1 < a0 - carmode.TOL_A:
|
||||
what = "lower"
|
||||
elif sun.target_w is None:
|
||||
what = "wait-unknown"
|
||||
else:
|
||||
what = "steady"
|
||||
sent = []
|
||||
for kind, v, _t, ok in w.log[n_log:]:
|
||||
if kind == "current":
|
||||
sent.append(f"sent {v:g} A" + (" confirmed" if ok else ""))
|
||||
else:
|
||||
sent.append(f"phases {v}" + (" confirmed" if ok else ""))
|
||||
age = sun.age_s
|
||||
_LOG.debug("Solar step: t=%.1f age=%s decision=%s write=%s", now,
|
||||
"none" if age is None else f"{age:.1f}", what,
|
||||
"; ".join(sent) or "none")
|
||||
|
||||
def car_sun_own(self, snap, now):
|
||||
"""EV-51 (PM): every decision on the meter's AGE is taken at the writer
|
||||
step's own age (now minus the meter's last reading), not the age the
|
||||
cycle saw one step earlier: the write block while the meter is silent
|
||||
(N8), the unknown/pause timing (held reads too) and the late-readings
|
||||
hold with its stale rule. The meter's VALUES (spare, target) stay the
|
||||
cycle's only while the step's own age says the meter is fresh; once it
|
||||
is past `meter_max_age_s` they are unknown (C23). Arrival sources'
|
||||
`car_spare_w` keeps the cycle's age."""
|
||||
own = copy.copy(snap)
|
||||
own.silent = self._car_meter_silent()
|
||||
own.unknown_s = self._car_meter_over_s()
|
||||
own.age_s = self.p1.age_s() if self.p1_enabled else None
|
||||
own.meter_back = snap.unknown_s > 0.0 and own.unknown_s <= 0.0
|
||||
stale = float(self.o.get("stale_input_s", 15))
|
||||
late = self._car_late_s # the verdict stands: it has aged since
|
||||
if late is not None and self._car_late_mono is not None:
|
||||
late += max(0.0, now - self._car_late_mono)
|
||||
own.hold = late is not None and late < stale
|
||||
if own.silent or (late is not None and late >= stale):
|
||||
# The stale rule on the step's own age / own late (C23): a spare
|
||||
# read from data the own age calls old starts or raises nothing.
|
||||
own.spare_w = own.target_w = None
|
||||
return own
|
||||
|
||||
async def _car_step_run(self, held, now, sun) -> None:
|
||||
if held:
|
||||
# EV-20 rig round 2 (PM): the charger missed a read for less than
|
||||
# `stale_input_s`; the last trusted figure stands and nothing is
|
||||
# decided or written from the gap. No writer steps and no plan
|
||||
# count (start, phase change, hold) moves (review r3, PM design);
|
||||
# a decision due now runs on the next real reading. The one
|
||||
# exception: Solar's pause by the meter's age (C18).
|
||||
if sun is not None and self.car_writing():
|
||||
await self.car_solar.held_pause(
|
||||
self.charger, self.car.reading, sun=sun, now=now,
|
||||
tracker=self.car)
|
||||
return
|
||||
if self.car_mode != carmode.SOLAR and not held:
|
||||
await self.car_writer.step(
|
||||
self.charger, self.car.reading, mode=self.car_mode,
|
||||
want_a=self.car_a, want_phases=self.car_n, rev=self.car_rev,
|
||||
@@ -380,10 +467,6 @@ class CarMixin:
|
||||
if self.car_mode == carmode.SOLAR or w.engaged:
|
||||
# C6: one write clock: Manual's latest non-zero write counts.
|
||||
w.other_at = self.car_writer.nonzero_at
|
||||
sun = None
|
||||
if self.car_mode == carmode.SOLAR:
|
||||
sun = getattr(self, "_car_sun_now", None) \
|
||||
or self.car_sun_inputs(now)
|
||||
await w.step(
|
||||
self.charger, self.car.reading, mode=self.car_mode,
|
||||
sun=sun,
|
||||
@@ -452,7 +535,29 @@ class CarMixin:
|
||||
hold=hold, auto=ph not in ("1", "3"),
|
||||
start_s=60.0 * carmode.solar_option(o, "ev_start_min"),
|
||||
pause_s=60.0 * carmode.solar_option(o, "ev_pause_min"),
|
||||
spare_w=spare, room_w=room, margin_w=margin, first=self.car_first)
|
||||
spare_w=spare, room_w=room, margin_w=margin, first=self.car_first,
|
||||
unknown_s=self._car_meter_over_s() if spare is None else 0.0,
|
||||
silent=self._car_meter_silent())
|
||||
|
||||
def _car_meter_silent(self) -> bool:
|
||||
"""SPIKE-06 C17 (N8): is the meter known silent (its age past
|
||||
`meter_max_age_s`)? Then Solar writes no non-zero current."""
|
||||
if not self.p1_enabled:
|
||||
return False
|
||||
age = self.p1.age_s()
|
||||
bound = float(self.o.get("meter_max_age_s", 30) or 30)
|
||||
return age is not None and age > bound
|
||||
|
||||
def _car_meter_over_s(self) -> float:
|
||||
"""EV-20 rig round 2 (PM): on `ha_signed`, how far the meter's age is
|
||||
past `meter_max_age_s`, so Solar's pause comes at that age +
|
||||
`ev_pause_min` (checked every cycle), not a cycle or two later."""
|
||||
if not self.p1_enabled \
|
||||
or str(self.o.get("meter_source") or "") != "ha_signed":
|
||||
return 0.0
|
||||
age = self.p1.age_s()
|
||||
bound = float(self.o.get("meter_max_age_s", 30) or 30)
|
||||
return 0.0 if age is None else max(0.0, age - bound)
|
||||
|
||||
def _car_sun_tick(self, mono) -> None:
|
||||
"""Solar kWh: per cycle, in Solar only, the car's power up to the sun
|
||||
|
||||
@@ -254,6 +254,7 @@ class CycleMixin:
|
||||
stale_after = float(self.o.get("stale_input_s", 15))
|
||||
late_s = self._readings_late(site_standing) # SAFETY-128
|
||||
self._car_late_s = late_s # EV-20: Solar holds, then the stale rule
|
||||
self._car_late_mono = self._now_mono # EV-51: when that verdict was read
|
||||
self._late_zero = late_s is not None and late_s >= stale_after
|
||||
# ⚠️ `any`, NOT the sole unit's. The hold exists so a single missed
|
||||
# poll does not become a fault; a LATCHED inverter must still reach the
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: GoodWe RS485 Controller
|
||||
version: "0.24.0"
|
||||
version: "0.25.0"
|
||||
slug: goodwe_controller
|
||||
description: >-
|
||||
Drives a GoodWe ES/BP battery inverter over its RS485 EMS port by sending it a
|
||||
|
||||
@@ -605,11 +605,14 @@ for nm, kw in (("T2", dict(house=H.shape(14000.0), b=const(800.0))),
|
||||
r10b, tr10b = H.run(a=ZERO, extra=unavailable(E + 1, E + 2), **kw)
|
||||
summary(f"T10(b) {nm}", r10b, tr10b)
|
||||
if nm == "T2":
|
||||
# EV-20 rig round 2 (PM): a charger read missing for less than
|
||||
# stale_input_s keeps the last trusted figure, so this one-cycle gap
|
||||
# is no longer an unknown car figure (was: the alarm for that cycle).
|
||||
check("T10(b) T2: the charger unavailable for one cycle (E+1): the "
|
||||
"alarm stands for that cycle only (Expected 5)",
|
||||
H.edges(tr10b) == [E + 1]
|
||||
and all(not x["alarm"] for x in H.window(tr10b, E + 2, E + 899))
|
||||
and all(x["explains"] for x in H.window(tr10b, E + 2, E + 899)
|
||||
"last trusted figure stands (EV-20), no alarm edge, the car "
|
||||
"explains every limited cycle",
|
||||
H.edges(tr10b) == [] and quiet(r10b, tr10b)
|
||||
and all(x["explains"] for x in H.window(tr10b, E, E + 899)
|
||||
if x["lim"]))
|
||||
else:
|
||||
check("T10(b) T5: the alarm at the base second and it stands",
|
||||
@@ -813,6 +816,21 @@ def per_quarter(ts):
|
||||
return out
|
||||
|
||||
|
||||
# EV-20 rig round 2: ONE failed charger read in the T2 shape. The tracker keeps
|
||||
# the last trusted figure for a gap under `stale_input_s`, so the car still
|
||||
# explains the peak and no floor alarm comes (rig: a false FLOOR_LIMITED 1-2 s
|
||||
# after a single read gap, on base and head).
|
||||
for gap in (1, 2):
|
||||
rg, trg = H.run(H.shape(14000.0), a=ZERO, b=const(800.0),
|
||||
extra={E + 30: lambda p, c: p.ch.go_unavailable(),
|
||||
E + 30 + gap: lambda p, c: p.ch.go_unavailable(
|
||||
False)})
|
||||
wg, limg = summary(f"T-gap {gap} s", rg, trg)
|
||||
check(f"T-gap: {gap} missed charger read(s) at E+30: no "
|
||||
f"goodwe_peak_soc_floor, no FLOOR_LIMITED ERROR, no red peak_guard "
|
||||
f"row, the car explains every limited cycle",
|
||||
quiet(rg, trg) and all_explained(limg))
|
||||
|
||||
# Cover off, the T9(c) liar at the reserve: the guard's own engagement flips
|
||||
# as the liar's figure is corroborated now and then (its input is
|
||||
# `car_exclude`), pre-existing (base: 4 edges). Printed, not graded here.
|
||||
|
||||
@@ -502,4 +502,289 @@ for race in (True, False):
|
||||
nevers(r, f"C13 controller [race={race}]")
|
||||
|
||||
|
||||
# =========================================================================== #
|
||||
print("\n7. RIG ROUND 2: A SHORT CHARGER READ GAP; THE ha_signed PAUSE BY AGE")
|
||||
# =========================================================================== #
|
||||
# Full sun, Car first, charging 10 A from 120 s; the charger does not answer
|
||||
# for 1, 2 or 16 cycles at 600 s (Home Assistant shows it unavailable).
|
||||
def gap_run(n, beside=False):
|
||||
sim = SimCharger(setpoint_a=0)
|
||||
if beside:
|
||||
sim.lag_s = 1.0
|
||||
return S.drive(const(500.0), const(2900.0), dur=1100, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, sim=sim, beside=beside,
|
||||
events={600: lambda p, c: p.ch.go_unavailable(),
|
||||
600 + n: lambda p, c: p.ch.go_unavailable(False)})
|
||||
|
||||
|
||||
for n in (1, 2):
|
||||
for beside in (False, True):
|
||||
r = gap_run(n, beside)
|
||||
w = cur_writes(r)
|
||||
late = [(t, a) for t, a, _ in w if t >= 590]
|
||||
unk = [x["t"] for x in r["trace"] if 590 <= x["t"] < 1100
|
||||
and x["spare"] is None]
|
||||
check(f"read gap of {n} sample(s) at 600 s [beside={beside}]: no "
|
||||
f"write and no pause after it, the spare stays known (writes "
|
||||
f"from 590 s {late}, unknown {unk[:3]})",
|
||||
late == [] and unk == [] and r["sim"].power_w > 2000.0)
|
||||
nevers(r, f"read gap {n} [beside={beside}]")
|
||||
|
||||
# 16 s (>= stale_input_s): the safe path as before. The charger is taken as
|
||||
# gone; on its return Solar writes 0 A first (D2), then the start rule.
|
||||
r = gap_run(16)
|
||||
w = cur_writes(r)
|
||||
late = [(t, a) for t, a, _ in w if t >= 590]
|
||||
check(f"read gap of 16 s: the safe path, 0 A first on the return, then the "
|
||||
f"start rule ({late[:3]})",
|
||||
present(nth(late, 0)) and nth(late, 0)[1] == 0.0
|
||||
and 616 <= nth(late, 0)[0] <= 620 and present(nth(late, 1))
|
||||
and nth(late, 1)[1] > 0.0)
|
||||
|
||||
# The held figure neither arms nor clears the stuck check: a frozen reading
|
||||
# after an accepted write is still stuck, with a 2-sample gap inside the 60 s
|
||||
# (flagged at the first real reading at or after +60 s).
|
||||
tr = CH.CarTracker()
|
||||
for i in range(-5, 1):
|
||||
tr.observe(rd(), TS + i, UTC, DAY)
|
||||
tr.begin_write()
|
||||
tr.end_write(TS + 1)
|
||||
tr.note_write(TS, 10.0, 0.0, True)
|
||||
gone = CH.ChargerReading(why="no answer")
|
||||
st_at = None
|
||||
for i in range(1, 90):
|
||||
if i in (59, 60):
|
||||
tr.observe(gone, TS + i, UTC, DAY)
|
||||
else:
|
||||
tr.observe(rd(), TS + i, UTC, DAY)
|
||||
if st_at is None and tr.stuck(TS + i):
|
||||
st_at = i
|
||||
check(f"frozen reading with a 2-sample gap at +59/+60: still stuck, at the "
|
||||
f"first real reading after +60 (+{st_at})", st_at == 61)
|
||||
tr = CH.CarTracker()
|
||||
for i in range(-5, 1):
|
||||
tr.observe(rd(), TS + i, UTC, DAY)
|
||||
tr.begin_write()
|
||||
tr.end_write(TS + 1)
|
||||
tr.note_write(TS, 10.0, 0.0, True)
|
||||
for i in range(1, 70):
|
||||
tr.observe(rd(), TS + i, UTC, DAY)
|
||||
tr.observe(gone, TS + 70, UTC, DAY)
|
||||
check("a held gap does not clear a stuck verdict (+70 s gap, still stuck)",
|
||||
tr.stuck(TS + 70) and getattr(tr, "held", None) is True)
|
||||
|
||||
# ha_signed: the pause is timed from the meter's age (PM): unknown since the
|
||||
# age passed meter_max_age_s, so 0 A when the age reaches 330 s. A plan
|
||||
# stepped every 10 s (the rig's cycle) that first sees the unknown sun at age
|
||||
# 57 (a cycle or two after the bound passed) still pauses at the first step at
|
||||
# or after age 330 (bound: 330 + one cycle); timed from the noticing step it
|
||||
# would be age 357.
|
||||
plan = carmode.SolarPlan()
|
||||
plan.reset(1)
|
||||
kw = dict(n_now=1, auto=False, clamp=16.0, start_s=120.0, pause_s=300.0)
|
||||
t = 0.0
|
||||
while plan.a <= 0.0 and t < 400:
|
||||
plan.step(t, target_w=2900.0, **kw)
|
||||
t += 10.0
|
||||
age0 = t + 3.0 # the meter's last reading; the bound passes at +30
|
||||
paused_at = None
|
||||
while t < age0 + 400:
|
||||
age = t - age0
|
||||
over = max(0.0, age - 30.0)
|
||||
try:
|
||||
plan.step(t, target_w=None if age > 50.0 else 2900.0,
|
||||
unknown_s=over if age > 50.0 else 0.0, **kw)
|
||||
except TypeError: # a build without the age rule
|
||||
plan.step(t, target_w=None if age > 50.0 else 2900.0, **kw)
|
||||
if plan.a == 0.0 and paused_at is None:
|
||||
paused_at = age
|
||||
break
|
||||
t += 10.0
|
||||
check(f"ha_signed pause by age, plan stepped every 10 s: 0 A at meter age "
|
||||
f"{paused_at} (330 <= age <= 340)",
|
||||
paused_at is not None and 330.0 <= paused_at <= 340.0)
|
||||
# The controller hands Solar that age: 40 s after the meter went silent at
|
||||
# 300 s, `unknown_s` is 10 (age 40 - 30).
|
||||
seen = {}
|
||||
r = S.drive(const(500.0), const(2900.0), dur=360, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, opts={"ev_phases": "1"},
|
||||
events={300: lambda p, c: setattr(p, "meter_on", False),
|
||||
340: lambda p, c: seen.update(
|
||||
u=getattr(c.car_sun_inputs(p.clock[0]),
|
||||
"unknown_s", None))})
|
||||
check(f"ha_signed: 40 s after the meter went silent Solar is told the sun "
|
||||
f"has been unknown for 10 s ({seen})",
|
||||
seen.get("u") is not None and 9.0 <= seen["u"] <= 12.0)
|
||||
|
||||
# =========================================================================== #
|
||||
print("\n8. SPIKE-06 ROUND 3: NO NON-ZERO WRITE WHILE THE METER IS SILENT (C17);")
|
||||
print(" THE AGE PAUSE ON A HELD READ (C18)")
|
||||
# =========================================================================== #
|
||||
# C17 (a): 7 A, a raise to 10 A at 340 s that the charger ignores, the meter
|
||||
# silent from 345 s (ha_signed). No re-send of the 10 A (the retry would come
|
||||
# at 400 s, meter age 55 s); 0 A when the age reaches 330 s.
|
||||
sim = TSim(setpoint_a=0, windows=[(335.0, 350.0, "ignore")])
|
||||
r = S.drive(const(500.0), lambda t: 3000.0 if t >= 340 else 2300.0,
|
||||
dur=900, first="car", socs={"a": 100.0, "b": 100.0}, sim=sim,
|
||||
opts={"ev_phases": "1"},
|
||||
events={345: lambda p, c: setattr(p, "meter_on", False)})
|
||||
w = cur_writes(r)
|
||||
nz = [(t, a) for t, a, _ in w if a > 0.0 and t > 345 + 30]
|
||||
z = [t for t, a, _ in w if a == 0.0 and t > 345]
|
||||
raise_ = [(t, a, ok) for t, a, ok in w if 330 <= t <= 345]
|
||||
check(f"C17 (a): an ignored raise ({raise_}), then the meter silent from "
|
||||
f"345 s: no re-send while it is silent ({nz}), 0 A at meter age 330 "
|
||||
f"(+2) ({z[:1]})",
|
||||
present(nth(raise_, 0)) and nth(raise_, 0)[2] is False and nz == []
|
||||
and present(nth(z, 0)) and 345 + 329 <= nth(z, 0) <= 345 + 333)
|
||||
nevers(r, "C17 (a)")
|
||||
|
||||
# C17 (b): a 1 -> 3 phase change starts at 301 s (its 0 A); the meter has been
|
||||
# silent since 276 s, so its age passes 30 s at 307 s, before the closing
|
||||
# current (313 s without silence). The change ends at its 0 A: no closing
|
||||
# current, nothing non-zero until the meter is back.
|
||||
r = S.drive(const(500.0), const(7600.0), dur=900, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, car_phases=3,
|
||||
events={276: lambda p, c: setattr(p, "meter_on", False),
|
||||
800: lambda p, c: setattr(p, "meter_on", True)})
|
||||
w = cur_writes(r)
|
||||
seq0 = [t for t, a, _ in w if a == 0.0 and 295 <= t <= 305]
|
||||
nz = [(t, a) for t, a, _ in w if a > 0.0 and 306 < t < 800]
|
||||
check(f"C17 (b): a phase change under way when the meter goes silent ends at "
|
||||
f"its 0 A ({seq0}): no closing current, no non-zero write while silent "
|
||||
f"({nz}); writes {w[:6]}",
|
||||
present(nth(seq0, 0)) and nz == []
|
||||
and [a for t, a, _ in w if 301 <= t < 800][-1:] == [0.0])
|
||||
nevers(r, "C17 (b)")
|
||||
|
||||
# C18: a charger read gap on the very cycle the age pause is due (ha_signed,
|
||||
# meter silent from 300 s: due at 629 s without a gap, the meter's last sample
|
||||
# being at 299 s). The held cycle still steps Solar's pause: 0 A at 629 s, at
|
||||
# most one cycle later (f625011: 631 s with the gap from 629 s).
|
||||
for gap_at in (629, 630):
|
||||
r = S.drive(const(500.0), const(2900.0), dur=760, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, opts={"ev_phases": "1"},
|
||||
events={300: lambda p, c: setattr(p, "meter_on", False),
|
||||
gap_at: lambda p, c: p.ch.go_unavailable(),
|
||||
gap_at + 2: lambda p, c: p.ch.go_unavailable(False)})
|
||||
w = cur_writes(r)
|
||||
z = [t for t, a, _ in w if a == 0.0 and t > 300]
|
||||
check(f"C18: a 2-sample read gap from {gap_at} s, the age pause due at "
|
||||
f"629 s: 0 A at {z[:1]} (629-630)",
|
||||
present(nth(z, 0)) and 629 <= nth(z, 0) <= 630)
|
||||
|
||||
# =========================================================================== #
|
||||
print("\n9. SPIKE-06 C19: A READ GAP DURING A PHASE CHANGE")
|
||||
# =========================================================================== #
|
||||
# The C17 (b) shape without the silent meter: a 1 -> 3 change, its 0 A at
|
||||
# 301 s, select 3, closing current at 313 s. One to six failed charger reads
|
||||
# right after the select change nothing: the closing current comes on time
|
||||
# and no pause follows (0ef8de2: paused, no current until about 914 s).
|
||||
def phase_run(events):
|
||||
return S.drive(const(500.0), const(7600.0), dur=700, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, car_phases=3,
|
||||
events=events)
|
||||
|
||||
|
||||
for n in (1, 2, 6):
|
||||
r = phase_run({305: lambda p, c: p.ch.go_unavailable(),
|
||||
305 + n: lambda p, c: p.ch.go_unavailable(False)})
|
||||
w = cur_writes(r)
|
||||
close = [(t, a) for t, a, _ in w if a > 0.0 and 301 < t < 700]
|
||||
check(f"C19: {n} failed read(s) at 305 s, just after the select: the "
|
||||
f"closing current on time ({close[:2]}), no pause ({w[:5]})",
|
||||
present(nth(close, 0)) and 312 <= nth(close, 0)[0] <= 313 + n
|
||||
and [a for t, a, _ in w if 301 < t < 700 and a == 0.0] == [])
|
||||
nevers(r, f"C19 gap {n}")
|
||||
# A gap of stale_input_s or more during the change: the safe path as before.
|
||||
# The charger is taken as gone: nothing while it is away and no closing
|
||||
# current; on its return the change is dropped and Solar starts over (0 A
|
||||
# first, already standing here, so nothing is written; then the start rule,
|
||||
# which on the 3 phases the select left waits for the phase gap).
|
||||
r = phase_run({305: lambda p, c: p.ch.go_unavailable(),
|
||||
322: lambda p, c: p.ch.go_unavailable(False)})
|
||||
w = cur_writes(r)
|
||||
during = [(t, a) for t, a, _ in w if 305 <= t < 322]
|
||||
after = [(t, a) for t, a, _ in w if t >= 322]
|
||||
check(f"C19: a 17 s gap during the change takes the safe path: nothing while "
|
||||
f"away ({during}), no closing current, nothing non-zero before the "
|
||||
f"start rule after the return ({after[:2]})",
|
||||
during == [] and not [1 for t, a in after if a > 0.0 and t < 322 + 115]
|
||||
and r["c"].car_solar.seq is None)
|
||||
nevers(r, "C19 long gap")
|
||||
|
||||
# =========================================================================== #
|
||||
print("\n10. REVIEW R3: A HELD READ ON A DECISION CYCLE (PM design)")
|
||||
# =========================================================================== #
|
||||
# The reviewer's three shapes (house 500 W, Car first, 3-phase car). A 1- or
|
||||
# 2-sample read gap on the cycle a phase change or a switching start is due,
|
||||
# or on the cycle before it: the decision waits for the next real reading and
|
||||
# every write lands within 2 s of the run without the gap (a60ebd3: the wait
|
||||
# restarted, and 3 -> 1 became a 0 A pause in full sun).
|
||||
def sun_b(t):
|
||||
return 7600.0 if t < 1000 else (300.0 if t < 1400 else 2600.0)
|
||||
|
||||
|
||||
SHAPES = (("A 1 -> 3", const(7600.0), 700, 301),
|
||||
("B a start that needs 3 -> 1", sun_b, 1900, 1521),
|
||||
("C 3 -> 1", lambda t: 7600.0 if t < 1000 else 4300.0, 1700, 1301))
|
||||
|
||||
|
||||
def shape_run(sunf, dur, events=None):
|
||||
return S.drive(const(500.0), sunf, dur=dur, first="car",
|
||||
socs={"a": 100.0, "b": 100.0}, car_phases=3,
|
||||
events=events or {})
|
||||
|
||||
|
||||
def after(r, t0, t1):
|
||||
return [(t, a) for t, a, _ in cur_writes(r) if t0 <= t < t1]
|
||||
|
||||
|
||||
for name, sunf, dur, d in SHAPES:
|
||||
twin = after(shape_run(sunf, dur), d - 5, d + 200)
|
||||
for off in (-1, 0):
|
||||
for n in (1, 2):
|
||||
g = d + off
|
||||
r = shape_run(sunf, dur,
|
||||
{g: lambda p, c: p.ch.go_unavailable(),
|
||||
g + n: lambda p, c: p.ch.go_unavailable(False)})
|
||||
got = after(r, d - 5, d + 200)
|
||||
same = (len(got) == len(twin) and all(
|
||||
a1 == a2 and abs(t1 - t2) <= 2.0
|
||||
for (t1, a1), (t2, a2) in zip(got, twin)))
|
||||
check(f"review r3 [{name}] {n}-read gap at {g} (decision due "
|
||||
f"{d}): the writes of the run without the gap, within 2 s "
|
||||
f"({got[:4]} vs {twin[:4]})", same and bool(twin))
|
||||
nevers(r, f"review r3 [{name}] gap {n} at {g}")
|
||||
|
||||
# The hold's pause (low_since past ev_pause_min) never fires on a held cycle:
|
||||
# it comes on the next real reading, and only if that reading still says low.
|
||||
base = S.drive(const(500.0), lambda t: 900.0 if t >= 400 else 2900.0,
|
||||
dur=900, first="car", socs={"a": 100.0, "b": 100.0},
|
||||
opts={"ev_phases": "1"})
|
||||
z0 = nth([t for t, a, _ in cur_writes(base) if a == 0.0 and t > 400], 0)
|
||||
check(f"hold twin: 0 A at {z0} (300 s from the drop at 400, +2)",
|
||||
present(z0) and 699 <= z0 <= 702)
|
||||
if present(z0):
|
||||
zi = int(z0)
|
||||
r = S.drive(const(500.0), lambda t: 900.0 if t >= 400 else 2900.0,
|
||||
dur=900, first="car", socs={"a": 100.0, "b": 100.0},
|
||||
opts={"ev_phases": "1"},
|
||||
events={zi: lambda p, c: p.ch.go_unavailable(),
|
||||
zi + 1: lambda p, c: p.ch.go_unavailable(False)})
|
||||
z = [t for t, a, _ in cur_writes(r) if a == 0.0 and t > 400]
|
||||
check(f"hold pause due on a held read ({zi}): 0 A on the next real "
|
||||
f"reading ({z[:1]}), not on the held cycle",
|
||||
present(nth(z, 0)) and nth(z, 0) == zi + 1)
|
||||
r = S.drive(const(500.0),
|
||||
lambda t: 900.0 if 400 <= t < zi else 2900.0,
|
||||
dur=900, first="car", socs={"a": 100.0, "b": 100.0},
|
||||
opts={"ev_phases": "1"},
|
||||
events={zi: lambda p, c: p.ch.go_unavailable(),
|
||||
zi + 1: lambda p, c: p.ch.go_unavailable(False)})
|
||||
z = [t for t, a, _ in cur_writes(r) if a == 0.0 and t > 400]
|
||||
check(f"hold pause due on a held read ({zi}), the sun back from that "
|
||||
f"second, so the next real reading ({zi + 1}) is not low: no pause "
|
||||
f"({z[:1]})", z == [])
|
||||
|
||||
report()
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -137,11 +137,41 @@ class SunPlant:
|
||||
return True
|
||||
|
||||
|
||||
def _cycle_seconds(t0, dur, cyc, phase, jitter, cset):
|
||||
"""EV-51: the seconds a cycle runs, or None for every second."""
|
||||
if cset is not None:
|
||||
due = {int(x) for x in cset if t0 <= x < t0 + dur}
|
||||
if not due:
|
||||
raise ValueError("cset has no second inside the run")
|
||||
return due
|
||||
if jitter is not None:
|
||||
gaps = [int(g) for g in jitter]
|
||||
if not gaps or min(gaps) <= 0:
|
||||
raise ValueError("jitter needs gaps above 0")
|
||||
due, t, i = set(), int(t0), 0
|
||||
while t < t0 + dur:
|
||||
due.add(t)
|
||||
t += gaps[i % len(gaps)]
|
||||
i += 1
|
||||
return due
|
||||
if cyc != int(cyc) or cyc <= 0:
|
||||
raise ValueError("cyc must be a whole number of seconds above 0")
|
||||
if not 0 <= phase < cyc:
|
||||
raise ValueError("phase must be in [0, cyc)")
|
||||
if cyc == 1:
|
||||
return None
|
||||
due = {int(t0) + k for k in range(int(phase), int(dur), int(cyc))}
|
||||
if not due:
|
||||
raise ValueError("no cycle inside the run")
|
||||
return due
|
||||
|
||||
|
||||
def drive(house, sun, *, dur=600.0, ratings=None, socs=None, cap=3500.0,
|
||||
margin=100, opts=None, plug=True, setpoint=0, phases=1, mode="solar",
|
||||
first="batteries", events=None, sim=None, store=None, race=False,
|
||||
on_cycle=None, car_phases=3, t0=0.0, caps=None, finale=None,
|
||||
rows=False, plant_cls=None, beside=False, meter_change=False):
|
||||
rows=False, plant_cls=None, beside=False, meter_change=False,
|
||||
cyc=1, phase=0, jitter=None, cset=None):
|
||||
"""Run it. Returns a dict: plant, controller, charger, notifications with
|
||||
their second, and a per-second trace. `caps` ({unit: kWh}) lets each
|
||||
battery's level move with what it charges or gives; without it the
|
||||
@@ -152,7 +182,14 @@ def drive(house, sun, *, dur=600.0, ratings=None, socs=None, cap=3500.0,
|
||||
round 1): a write that waits for its read-back is still waiting when the
|
||||
next cycle reads the charger; it resumes after that read.
|
||||
`meter_change=True` publishes the meter as Home Assistant does on
|
||||
`ha_signed`: only when the whole-watt value changes."""
|
||||
`ha_signed`: only when the whole-watt value changes.
|
||||
EV-51, the cycle's cadence (the meter and the charger model still tick
|
||||
every 1 s; only the control cycle is thinned): `cyc` seconds between
|
||||
cycles and `phase` (the first cycle at t0 + phase), or `jitter`, a
|
||||
tuple of gaps used in turn (the first cycle at t0), or `cset`, the
|
||||
cycle seconds. The default (1 s) runs every second as before. A cadence
|
||||
that would run no cycle is a ValueError, never a vacuous pass."""
|
||||
due = _cycle_seconds(t0, dur, cyc, phase, jitter, cset)
|
||||
ratings = ratings or {"a": 5000.0, "b": 4600.0}
|
||||
socs = socs or {u: 50.0 for u in ratings}
|
||||
sim = sim or SimCharger(setpoint_a=setpoint)
|
||||
@@ -252,6 +289,12 @@ def drive(house, sun, *, dur=600.0, ratings=None, socs=None, cap=3500.0,
|
||||
"ha_signed", imp, exp, phases=1,
|
||||
ingest_ts=rig.BASE + timedelta(seconds=ts),
|
||||
ingest_mono=ts))
|
||||
if due is not None and int(t) not in due:
|
||||
for u, kwh in (caps or {}).items():
|
||||
lv = plant.socs[u] - plant.batt_of(u, t) / 36000.0 / kwh
|
||||
plant.socs[u] = max(0.0, min(100.0, lv))
|
||||
t += 1.0
|
||||
continue
|
||||
await c.read_inputs(now_mono=t)
|
||||
if race:
|
||||
await c.car_settle()
|
||||
|
||||
Reference in New Issue
Block a user