marstek-venus-rs485-node-red icon indicating copy to clipboard operation
marstek-venus-rs485-node-red copied to clipboard

sensor.hbc_energy_prices_data exceed maximum size of 16384 bytes

Open wauswaus opened this issue 2 months ago • 3 comments

I quite often see this warning in my HA log after setting up everything for the dynamic strategy:

State attributes for sensor.hbc_energy_prices_data exceed maximum size of 16384 bytes. This can cause database performance issues; Attributes will not be stored

Running HBC 4.15.1

wauswaus avatar Sep 12 '26 18:09 wauswaus

This is a known HA recorder limit (MAX_LENGTH_STATE_ATTRS, 16384 bytes) tripping on sensor.hbc_energy_prices_data. On my own install (HBC 4.15.1, dynamic strategy) the attributes sat at ~11.8 KB with just today's prices — 72% of the limit — so it doesn't take much (tomorrow's prices loading, an extra day) to push it over.

The cause: the marks attribute duplicates the full price series a second time — each of the 96 quarter-hour points is stored as {start, end, price, mark, is_now}, while start/end/price are already available elsewhere (the top-level start attribute + datapoints_per_hour, and the separate compact prices array at the same index). marks alone was 92% of the payload.

Quick self-fix, no functional change: in Node-RED, open Strategy Dynamic → "Determine dynamic strategy", find this line near the end (step 5, "Store results"):

js RED.util.setMessageProperty(msg,"dynamic.data_all.list_marked",intervals,true);

Replace it with:

js const marksSlank = intervals.map(function(iv){ return { mark: iv.mark, is_now: iv.is_now }; }); RED.util.setMessageProperty(msg,"dynamic.data_all.list_marked",marksSlank,true);

Deploy. This only trims the published copy — the intervals variable used afterwards for the spread calculation (net_spread/gross_spread) is untouched, so nothing else changes. On my system this took the attribute payload from 11.827 → 3.783 bytes (−68%), evaluation time and Dynamic strategy behaviour unaffected (checked net_spread/gross_spread before/after, both still correct).

satscan1 avatar Sep 14 '26 10:09 satscan1

Correction to my earlier comment — please don't apply that snippet as-is

Apologies: the fix I posted above is wrong. Removing price from marks breaks the price-interval charts on both the HBC Dynamic tab and the HPVC dashboard — they read iv.start and iv.price directly from marks via the ApexCharts data_generator. If you already applied it, the charts will render empty (axes only, no bars).

Corrected version — same place (Strategy Dynamic → "Determine dynamic strategy", step 5 "Store results"), replace:

js RED.util.setMessageProperty(msg,"dynamic.data_all.list_marked",intervals,true);

with:

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 plenty for cent/kWh mark: iv.mark, is_now: iv.is_now })); RED.util.setMessageProperty(msg,"dynamic.data_all.list_marked",marksSlank,true);

This keeps every field the charts actually use and only drops end (unused) plus shrinks the encoding. Measured here at 192 intervals (today + tomorrow): 17,291 → 14,100 bytes, 86% of the 16384 limit, charts fully intact — verified live on both dashboards.

Note the headroom is modest: at 86% this fixes the warning for a standard quarter-hourly setup, but a finer resolution could still overflow. Tracking the structural side in #194.

satscan1 avatar Sep 14 '26 15:09 satscan1

Why open a new issue while we already have this one?

wauswaus avatar Sep 14 '26 15:09 wauswaus