Issue: sensor.hbc_energy_prices_data attributes routinely approach/exceed HA's 16384-byte recorder limit
On a live install (HBC 4.15.1, dynamic strategy, 96 quarter-hour points for today only) the sensor's attributes measure 11,827 bytes — 72% of HA's MAX_LENGTH_STATE_ATTRS limit — before tomorrow's prices are even loaded. With both days' prices (192 points), this reliably tips over 16384 and HA silently drops the attributes (homeassistant.components.recorder.db_schema warning), which is presumably what several users are seeing.
Root cause: the marks attribute duplicates the full price series a second time. Each point is published as {start, end, price, mark, is_now}, while start/end are derivable from the sensor's own top-level start + datapoints_per_hour, and price is already in the separate prices array at the same index. On this install marks alone accounted for 92% of the total payload (10,868 of 11,827 bytes) — roughly 14× larger than prices for the same 96 points.
Suggested fix, in Strategy Dynamic → "Determine dynamic strategy" (step 5, "Store results"):
js RED.util.setMessageProperty(msg,"dynamic.data_all.list_marked",intervals,true);
→ publish a trimmed copy instead of the full intervals array:
js const marksSlank = intervals.map(iv => ({ mark: iv.mark, is_now: iv.is_now })); RED.util.setMessageProperty(msg,"dynamic.data_all.list_marked",marksSlank,true);
intervals itself stays untouched for the subsequent spread calculation (step 6, net_spread/gross_spread), so this is attribute-publishing only, no behavioural change. Verified on this install: attributes 11,827 → 3,783 bytes (−68%), net_spread/gross_spread identical before/after, Dynamic strategy switching (Strategy cheapest/Strategy expensive) unaffected.
If the dashboard or any consumer relies on start/end/price inside individual marks entries specifically (rather than deriving them), happy to share the exact diff so it can be reviewed before merging — this was applied and tested live but only against this install's own Lovelace cards.
Correction: both start and price must stay — the win is in formatting, not in dropping fields
My original proposal was wrong and I want to correct it before anyone implements it. Dropping price (and start) from marks breaks the price-interval charts on both the HBC Dynamic tab and the HPVC dashboard. The ApexCharts data_generator reads directly from marks:
js const marks = entity.attributes.marks || []; return marks.map(iv => ({ x: new Date(iv.start).getTime(), y: iv.price, fillColor: iv.is_now ? '#009ac7' : (colours[iv.mark] || '#9e9e9e') }));
So start, price, mark and is_now are all consumed per interval. Only end is genuinely unused.
What actually works — keep every consumed field, shrink the encoding:
js const marksSlank = intervals.map(iv => ({ start: new Date(iv.start).getTime(), // epoch ms instead of ISO string price: Math.round(iv.price * 10) / 10, // 1 decimal is enough for cent/kWh mark: iv.mark, is_now: iv.is_now })); RED.util.setMessageProperty(msg,"dynamic.data_all.list_marked",marksSlank,true);
new Date(iv.start).getTime() still works unchanged in the chart — ApexCharts accepts the epoch number directly, and new Date(number) is a no-op.
Measured on this install, 192 intervals (today + tomorrow):
Variant Attributes % of 16384 limit Charts Unchanged (ISO string, full precision, incl. end) 17,291 bytes 106% ✅ (but attributes dropped by recorder) My original proposal (no start, no price) 3,783 bytes 23% ❌ broken Corrected (epoch + 1 decimal, no end) 14,100 bytes 86% ✅
Breakdown of the corrected version: dropping end ≈ −11%, epoch instead of ISO ≈ −18%, rounding price ≈ −2%.
That brings it under the limit with the charts intact — verified live, both dashboards render the full 48h price curve with correct high/low/now colouring.
Note this is tighter than ideal: 86% at 192 intervals means installs with a finer resolution (e.g. more datapoints_per_hour) would still overflow. If you want more headroom, the structural fix is moving the series out of state attributes entirely and having the cards read it another way — but the change above is the minimal one that fixes the reported warning without breaking anything.
Apologies for the incorrect first proposal: I tested it for attribute size but not against the cards that consume the data.