Commit 4e92beb
committed
fix(octopus): split a slot around a fully-contained overlap instead of losing its remainder (#4497)
fetch.py merges the HA Octopus Energy integration's completed_dispatches
ahead of planned_dispatches unconditionally. load_octopus_slots()'s overlap
dedup processes slots in that order, but could only ever trim one edge of
a slot against an already-decoded one, or drop it entirely if fully
contained - it had no path to split a slot that fully CONTAINS an
already-decoded one. A short completed historical interval sitting inside
a much longer still-active planned interval therefore truncated the
planned interval down to whatever sliver preceded the completed interval,
silently discarding its entire future remainder (e.g. a planned
07:59-16:00 dispatch containing a 08:00-09:00 completed interval collapsed
to 07:59-08:00, already in the past). Reported with an exact repro and
code trace by @cparmar.
The overlap resolution now subtracts each already-decoded slot's span from
the new slot's remaining segments, which can produce zero, one, or two
pieces - the two-piece case is the one that was missing. kwh is only
rescaled proportionally when a slot is actually split into multiple
pieces; the existing single-edge-trim behaviour (and its energy value)
is unchanged, preserving the existing hard-coded regression expectations
in test_octopus_slots.py.1 parent 4bb7841 commit 4e92beb
2 files changed
Lines changed: 79 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2565 | 2565 | | |
2566 | 2566 | | |
2567 | 2567 | | |
2568 | | - | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
2569 | 2580 | | |
2570 | 2581 | | |
2571 | | - | |
2572 | | - | |
2573 | | - | |
2574 | | - | |
2575 | | - | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
2576 | 2589 | | |
2577 | | - | |
2578 | | - | |
2579 | | - | |
2580 | | - | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
2581 | 2602 | | |
2582 | 2603 | | |
2583 | 2604 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
197 | 245 | | |
198 | 246 | | |
199 | 247 | | |
| |||
0 commit comments