Commit ffe1c8d
committed
Fix consumption-entity resolution: registry lookup instead of guessed entity_id
Verifying the hourly-profile data path surfaced the reason the profile-aware
overnight reserve might not take effect: _resolve_consumption_entity GUESSED
the inverter load sensor's entity_id as `sensor.{title}_{key}`. But HA derives
the entity_id from the slugified friendly NAME, e.g. "Homeload Day Cost Energy
(0.1KWh)" → `sensor.<title>_homeload_day_cost_energy_0_1kwh` — so the guess
never matched, hass.states.get() returned None, resolution failed, and the
hourly profile silently fell back to a FLAT daily/24 distribution. A flat
profile makes the profile-aware reserve identical to the old flat reserve, so
the daytime-EV phantom-deficit fix would have had no effect on real installs.
Now resolves the entity via the entity registry using the exact unique_id the
integration assigned (`{entry_id}_{key}`) — exact and rename-proof. Keeps the
override entity as first choice and the old title-guess as a last-resort
fallback.
Rest of the path verified sound: recorder statistics_during_period for hourly
buckets, 7-day averaging, persisted + recomputed on startup (no cold-start
gap), exposed as consumption_hourly_profile for inspection.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9LAQ5ET6SU9dLWULxv2uF1 parent 284b7fa commit ffe1c8d
2 files changed
Lines changed: 58 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1313 | 1313 | | |
1314 | 1314 | | |
1315 | 1315 | | |
1316 | | - | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
1317 | 1344 | | |
1318 | 1345 | | |
1319 | 1346 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1734 | 1734 | | |
1735 | 1735 | | |
1736 | 1736 | | |
1737 | | - | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
1738 | 1753 | | |
1739 | 1754 | | |
1740 | | - | |
| 1755 | + | |
| 1756 | + | |
| 1757 | + | |
| 1758 | + | |
1741 | 1759 | | |
1742 | 1760 | | |
1743 | 1761 | | |
1744 | 1762 | | |
1745 | 1763 | | |
| 1764 | + | |
| 1765 | + | |
| 1766 | + | |
| 1767 | + | |
| 1768 | + | |
| 1769 | + | |
| 1770 | + | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
1746 | 1774 | | |
1747 | 1775 | | |
1748 | 1776 | | |
| |||
0 commit comments