Skip to main content

Historical Data (per-inverter parameter history)

Status: All five phases are built (2026-10-07), pass unit and Postgres integration tests, and run in local dev. Not yet deployed to AWS, and the spec-evidence parameter mappings are not yet checked on hardware (§7). This page is the design of record for the per-inverter Historical Data screen; the client contract is in the Historical Data integration guide. The energy Analytics screen it builds on is in analytics.md.

1. What the screen needs​

The screen has two different modes behind one tab bar:

TabsFilter listChart
Day, Week~80–110 parameters, grouped: Basic Information, Electricity Generation, Grid, Consumption, Battery, BMS, Temperature, Other, Generator, UPS Load, UPS Load2, MeterOne line per selected parameter over time
Month, Year, TotalSix energy flows: Production, Grid Feed-in, Consumption, Electricity Purchasing, Charging Capacity, Discharging CapacityBars per day, per month, or per year

Confirmed decisions (2026-10-07):

#DecisionOutcome
H1Day/Week history depthExactly 3 months back from today (calendar months, in the plant's timezone)
H2WeekMonday–Sunday calendar week containing the picked date
H3TotalOne bar per calendar year
H4Parameters a model can't reportShown disabled, never hidden and never drawn as 0

2. What exists, and the gap​

StoreHoldsKeptServes here
telemetry.readings (raw JSONB)Every decoded register, every 5 min (only default-cadence rows are stored)5 days (1-day chunks, uncompressed)Nothing long-term: too short for 3 months, too wide to keep longer
telemetry_15m~30 fixed canonical columns4 monthsOnly ~8 of the Day/Week parameters
energy_dailyThe six energy flows per local dayIndefiniteAll of Month / Year / Total

So Month/Year/Total needed only API work (§3). Day/Week needed a new store of per-parameter history (§4).

3. Month / Year / Total (Phase 1)​

get_analytics serves these tabs, with two additions made on 2026-10-07 (contract: analytics.md §4.1, integration guide):

  • Device-only scope. plantId omitted, deviceKey set. It reads one inverter the user owns, including one with no plant, which the plant-scoped request couldn't serve because devices.plant_id is nullable.
  • period: "total". Yearly bars from the first year with stored energy to today.
    • Earlier years are summed in SQL (AnalyticsReader.YearTotals). The current year is read as days, including today's live figure.
    • Both reads split at the same date (postgres.TotalSplit): 1 January, or up to 4 days earlier in early January. The last days of December may not be finalised yet, and only the live path computes them, so splitting exactly at 1 January would have dropped them from last year's bar. That was found and fixed in the 2026-10-07 audit. A device's age never changes how many rows are read.
    • Limitation: Total starts at the first rolled-up day (late September 2026, or up to 4 months earlier where deviceadmin backfill was run), not at the inverter's installation.

Filter → field: Production generated, Grid Feed-in gridExport, Consumption consumed, Electricity Purchasing gridImport, Charging Capacity batteryCharge, Discharging Capacity batteryDischarge. Filtering is client-side. A checkbox whose capabilities flag is false is disabled (H4).

Code: internal/analytics/period.go (KindTotal, GrainYear, WidenTotal), internal/analytics/response.go (yearPoints), internal/storage/postgres/analytics_total.go (OwnedDevice, FirstEnergyDate, TotalSplit, YearTotals), cmd/ws-gateway/analytics.go (buildDeviceAnalytics, readAnalytics).

Verification (2026-10-07), all passing:

  • Unit tests for period resolution, the yearly build, the null year, and the year-boundary split.
  • Gateway tests for the device-only scope, a device not owned, Total, and Total across New Year.
  • The existing plant-scope tests, unchanged.
  • TestAnalyticsReader_DeviceScopeAndYearTotals against a fresh TimescaleDB (npm run test:db).

4. Day / Week​

4.1 Parameter catalog: internal/histparams​

One standard list of 140 parameters in 14 groups, shaped like internal/canonical and internal/displaylabel (histparams.go, sources.go).

  • Per parameter:

    • Stable key. It is also the telemetry_params column, e.g. pv1_voltage_v.
    • Label and group.
    • Unit: W, var, V, A, Hz, °C, %, kWh, Ah, h, or none.
    • Kind:
      • instant: averaged in a Week bucket.
      • counter: an energy counter, last value in a Week bucket.
      • state: a status code, last value in a Week bucket.
    • Default: whether it is pre-selected, which is also what the Restore button returns to.
  • Per model: the flat-telemetry key(s) the value is read from.

    • The flat object already resolved variants: tcpserver decodes only the device's own variant's rows (modbus.Profile.ForVariant). It also resolved duplicate names: the bare key is the lowest address.
    • So a source is a list of keys and the first one present wins. Aotai's single-phase grid_voltage and three-phase grid_voltage_a are both register 18, documented once per variant, so a reading only ever carries one of them.
  • Units and support come from the spec.

    • Each source's unit factor is derived from the spec unit (kW → W ×1000, kVar → var ×1000, Wh → kWh ×0.001), never written by hand.
    • Whether a variant supports a parameter is read from the spec's per-row variant tags.
    • The canonical flows (pv_power_w, battery_soc_pct, the energy counters, …) are mapped wherever canonical.Supports says the model reports them.
  • Coverage:

    Model / variantParameters supported
    Aotai, single phase77 of 140
    Aotai, three phase124 of 140
    IP20 2–12 kW72 of 140
    IP20 3K6/5K (ASCII protocol, since 2026-11-23)33 of 140 (Total Grid Power, an estimate, since 2026-11-24)

    14 parameters no current model reports. They are listed so that every parameter of the app's reference list has a key and a reason, and a future model needs a mapping, not a migration: PV3/PV4 (both models have two strings), back-up energy, battery Ah, cell max/min voltage, and total production hours plus daily and total running hours. None of these is in either vendor's register workbook.

  • Evidence. Each mapping records what it rests on:

    • canonical: a canonical field, checked against hardware.
    • spec: the register's name, description and unit are unambiguous, but its value has not yet been compared with the device's own screen. Most mappings are spec (58 of Aotai single phase, 105 of three phase, 55 of IP20). Checking them on the bench devices is the main open item (§7).
  • Deliberately left out:

    • Registers whose spec unit is wrong: 25 IP20 ones (energy in W, inverter_voltage_setpoint in Hz) and Aotai gen_factor1..3 (W for a power factor).
    • IP20's 124 high/low word halves (no composition yet).
    • IP20 battery current and IP20 battery power: their sign convention is undocumented.
    • IP20 "UPS Load", where its output/load registers' meaning is unclear.
  • Reference list (2026-10-08, migration 0057). The app's 112-parameter reference list is entirely in the catalog. The mapping of each reference name to its key is pinned by reference_test.go and published in the integration guide. Migration 0057 added 23 parameters:

    • Per-phase grid power. Aotai output_power_a/b/c, and on single phase output_power, negated into grid_power_w's + importing. The single-phase sign was observed on hardware (see internal/canonical); three-phase is assumed to count the same way. IP20 phase_a/b/c_grid_power are read as reported; their sign is documented only for the total (+ buying).
    • Per-phase grid reactive power. Aotai reactive_power_a/b/c; on single phase, reactive_power, which is also the total.
    • BMS1, in the Battery group. The Aotai carries BMS values in two blocks:
      • The battery menu (registers 77–81) is the inverter's own copy. With the BMS link down, 79/81 switch to the inverter's own limits (120 A).
      • The BMS menu (310–318) is the BMS's own values, which freeze at the last ones sent when the link drops. With the link up, the two blocks agree: on logger i30000252761006466, 79/81 and 317/318 both read 30/95 A on 2026-10-06/07.
      • bms1_* reads 77, 79 and 81. BMS Temper1 and BMS Temperature are both register 77, BMS温度 in both languages, so bms1_temperature_c is sameAs bms_temperature_c.
      • Register 312 is labelled "second level BMS Temperature" in English, but 主控温度 (the BMS main-controller temperature) in the original Chinese. It is not mapped until it has been compared with the inverter's BMS screen. (A first version of 0057 pointed bms_temperature_c at 312; that was reverted before release, so the key's meaning never changed.)
    • Grid buy/sell counters while the meter is offline (Aotai, product decision 2026-10-09). internal/canonical withholds grid_import/export_energy_today/total_kwh unless meter_com_status is 1, because the meter is their source. The Historical Data parameters show them as 0 instead (meterOrZero), so they are always selectable, and switch to the meter's values once it is online. A reading that did not decode meter_com_status stores nothing. Only the parameter history is filled; analytics still sees these counters as absent, so it does not show a false 0 kWh import.
    • BMS link gate (Aotai). Every Aotai BMS parameter (77–81 and 310–318) is extracted only while bms_com_status (85) is 1. Without that, the bench unit charted stale values: the link was down in 274 of its 276 readings, and the battery-pile voltage stayed at 53.1 V while the inverter's own battery voltage moved. With the link down for a day, the catalog reports these parameters as NOT_REPORTED. The IP20's BMS parameters are read only while bms_connection_status (65) is 1, 2 or 3, meaning a BMS is locked; this is the same gate internal/canonical uses for its SOC. Without a locked BMS, every BMS register on the bench IP20 held 0x7FFF, charted as a 3276.7 °C BMS temperature (322 of 600 readings, 2026-10-05/07).
    • Daily running hours. Aotai register 66, "Inverter energy times day" (逆变器日发电时长), in hours. This needed a new unit, h. It is the inverter's running time, not PV production hours. On the bench unit, with no PV connected, it rose 0.1 h every 6 minutes around the clock. It resets at the inverter's own midnight, and that unit's clock read 2021-05-24, so it does not reset at local midnight. A first version mapped it to Daily Production Hours; that was corrected before release. Daily Production Hours has no source on either model.
    • Generator. Per-phase reactive power (gen_power_q1..3, and gen_power_q_total on single phase), plus month and year energy (278, 280).
    • Fix. On single phase, gen_power_a_w now falls back to gen_power_total, as Back-Up Power A already falls back to back_up_power. Before, a single-phase Aotai showed Gen Phase-A Active Power as unsupported.
  • Why a parameter is unsupported (Unsupported, NOT_REPORTED).

    • MODEL_NOT_SUPPORTED: the model has no such register.
    • VARIANT_NOT_SUPPORTED: the model has it, but not on this variant.
    • NOT_REPORTED: the gateway's evidence check found the unit never sends it.
    • The reply carries this reason, so the app classifies nothing itself.
  • The same reading under two names (SameAs). When two parameters read the very same register with the same factor on a device's model and variant, the later one names the earlier one. Examples are the Aotai's Output group and its UPS Load group, and a single-phase total and its only phase. It is never set while the variant is unknown and the source depends on it.

  • Tests (histparams_test.go):

    • Every source key is a telemetry register in its spec, so it is actually polled, with a convertible unit and no conflicting units across duplicate definitions.
    • Keys are safe column names and every group is used.
    • Aotai variant support and the IP20 battery-power exclusion.
    • Extraction converts units and ignores non-numeric values and values out of float32 range.
    • Single-phase phase-A fallbacks and the negated grid-power sign, the three reasons, and SameAs.
    • reference_test.go: all 112 reference names map to distinct catalog keys in the reference's own groups.

4.2 Storage: telemetry_params (migrations 0049–0053)​

  • Shape. (time, device_id) plus one nullable REAL column per parameter, in catalog order, with primary key (device_id, time). Until the device-id re-key (migration 0072) the key was logger_id; it moved to devices.id so a device's history survives a logger swap.
    • TestColumnsMatchCatalog fails if the migration and the catalog ever differ.
    • Why REAL: the largest source is a uint32 × 0.1, which REAL stores without loss.
    • Why typed columns: adding a parameter is a nullable ADD COLUMN, and compressed chunks are read column by column.
  • Foreign key to devices(id) since 0072. Until then it had none: no compressed hypertable in this schema had one, and the combination was untried. 0072 added it with compression off, 0073 turned compression back on, and TestMigration_DeviceIDRekey proves the pair on the TimescaleDB image in use. The writer still inserts through JOIN devices … status <> 'revoked', so a row for a revoked or erased device is skipped rather than failing its whole batch, and erasure revokes a device before deleting anything.
  • Hypertable: 1-day chunks (0050). At 1M devices, shrink with set_chunk_time_interval; it affects new chunks only.
  • Compression: segmented by device_id (by logger_id until 0072), ordered by time DESC (0051, 0073), applied after 2 days (0052, 0074).
  • Retention: 94 days (0053). That is the longest 3-calendar-month span (92 days) plus 2 days, because retention drops whole chunks. The exact 3-month edge (H1) is enforced by the API.
  • Each TimescaleDB call is in its own migration file, per 0001's rule.

Rejected:

OptionWhy not
Continuous aggregate over raw JSONBChanging one mapping means dropping and recreating it, which loses all history older than raw retention (5 days). Per-model unit CASE logic would live in SQL.
Longer raw retentionKeeps every register (180–400 JSONB keys per row) to serve ~100
One row per parameter value~78k rows/s at 1M devices
5-min tier + 15-min aggregate tierSaves ~$25–45/month at 1M devices but adds an aggregate and a resolution change mid-history. Revisit once storage is measured (§7).

4.3 Write path: a separate durable consumer​

persistence-worker runs a second durable consumer on the TELEMETRY stream, persistence-worker-param-history (cmd/persistence-worker/params.go). It is not part of StoreTelemetry's transaction. There, a history error that classifyWriteErr marks permanent (undefined column, out of range) would terminate the record and discard the reading and the device-status update with it.

  • Stream fit. TELEMETRY uses limits retention with a 72 h max age, so a second consumer is allowed and has a 72 h lag budget.
  • Pull and batch. It fetches up to 500 messages (1 s wait) and writes one multi-row INSERT … ON CONFLICT DO NOTHING per fetch. The batch is split to stay under Postgres' 65,535 bind parameters. Messages are acked after the commit, and redelivery is a no-op.
  • Which records. postgres.ParamRowFromRecord applies StoreTelemetry's filter: default cadence and registered devices only, stamped with the same received-at instant. Records for an unsupported model produce no row and are acked.
  • Failures.
    • Transient: the batch is left unacked, redelivered after the ack wait, and the loop pauses 2 s.
    • Permanent: the batch is retried row by row. A bad row is terminated with an ERROR log line; the rest commit.
    • An unparseable timestamp is terminated.
    • MaxDeliver is 250, as for the other consumers.
  • First start. The consumer is created with DeliverAll, so on its first start it works through everything the stream still holds (up to 72 h) and that history fills in by itself. At today's fleet size that is minutes of work. At 1M devices it would be ~290M readings competing with live ingestion; for a first deploy at that scale, create it with DeliverNew and rely on backfill-params.
  • Backfill. deviceadmin backfill-params --yes (postgres.BackfillParamHistory) fills the history from the raw telemetry still held (5 days), fleet-wide. It is insert-only, so it is safe to re-run and to run while the consumer writes.
  • Observability. The repo has no metrics pipeline yet, so this is log-based. Every minute the consumer reads its pending count: it logs param history consumer is behind (WARN) at ≥ 100,000 pending (~90 s of the whole fleet at 1M devices, hours at today's size) and param history backlog (INFO) above 2,000. A CloudWatch metric filter on the WARN line is the alarm hook.
  • Erasure.
    • erasure.EraseTelemetry deletes telemetry_params in 30-day windows over its own span, not raw telemetry's: history is kept 3 months, raw readings 5 days.
    • FinishErasure sweeps the table once more inside its transaction, for a row the lagging consumer wrote just before the revoke. That sweep is savepointed, so a database without the table yet does not abort the erasure.
    • The audit record's TelemetryRows includes these rows.

4.4 API (ws-gateway, cmd/ws-gateway/history.go)​

Client contract: integration guide.

get_param_catalog {requestId, userId, deviceKey} → param_catalog. It returns every parameter, grouped. Since 2026-10-09 (product decision, replacing H4's disabled rows) every parameter has supported: true. One the device cannot report carries a reason (§4.1) and is not pre-selected, and a duplicate reading carries sameAs. The variant comes from devices.last_readings->>'_variant'.

get_param_history {requestId, userId, deviceKey, timezone, period, date, params[1..20]} → param_history:

PeriodRangegrainPoints per parameter
dayLocal day of datenative: every stored reading~288
weekMonday 00:00 to next Monday 00:00 local, the week containing date, clipped to today15m: avg for instant, last non-null value for counter/stateup to 672
  • Reply shape. Columnar: t[] plus values{key: []}, with 0 where a reading lacked the value (since 2026-10-09; the stored history keeps its NULLs, and only the reply fills them), along with period {kind, from, to, timezone, grain, availableFrom, isCurrent}, the parameter metadata, unavailable[] and dataAsOf. Values are rounded to 3 decimals, because a REAL 229.8 reads back as 229.8000030517578.
  • Time axis. Fifteen-minute UTC buckets align with every local offset (+5:30, +5:45); 1-hour buckets wouldn't. DST days have 92 or 100 slots, so the app plots by timestamp.
  • Retention edge. availableFrom is the later of today − 3 calendar months and the device's first stored reading (dataStartsAt, added 2026-10-07); a day inside the 3 months but before that reading answers NO_DATA_BEFORE.
  • reason follows evidence (2026-10-07). A parameter the model maps gets NOT_REPORTED when the device's last 288 readings never carried it and the requested period has no value for it — e.g. a standalone IP20 refuses its parallel-system bank. (Until 2026-10-09 this set supported: false.) See Analytics design §3.7.
  • Inverter and Output groups (migration 0056). 22 more columns; Output maps the Aotai's back-up port so both models share one name. Neither model has a PV temperature register.
    • A day before it → ok: true, no points, unavailable: PERIOD_OUTSIDE_RETENTION, with no query run.
    • A week straddling it is read from the edge.
  • Parameters without real values are read like any other: every parameter is a column, NULL where nothing was stored. They come back as all 0 with their reason, so a request always has the device's own time axis. MODEL_NOT_SUPPORTED is no longer an unavailable reason for the series.
  • Auth. AnalyticsReader.ParamDevice: the device must be the user's and not revoked; otherwise device_not_found. It uses the same dev-only userId model as get_analytics (decision D7); realtime-ticket auth is a production prerequisite for both.
  • Protection.
    • Shares the gateway-wide analytics slots and pool with get_analytics.
    • One request of each type in flight per connection; catalog and history have separate guards, so opening the screen isn't refused as busy.
    • 5 s timeout.
    • Column names come only from the catalog (pgx.Identifier), never from the request.
    • A malformed frame of either type is answered with invalid_request.
  • Queries. Day: SELECT time, <cols> FROM telemetry_params WHERE device_id = $1 AND time >= $2 AND time < $3 ORDER BY time. Week: the same, grouped by time_bucket('15 minutes', time). Either reads one device's segment, selected columns only.
  • Payload. About 50 KB for Day and 120 KB for Week at 20 parameters.

Export (CSV, Phase 5) is built client-side from the param_history reply already on screen (integration guide). No server work is needed.

5. Capacity and cost​

Assumptions, unmeasured until §7 is done:

  • 95 columns
  • ~380 B per uncompressed row
  • 10–20× compression
  • 288 rows per device per day
  • gp3 in us-east-1 at $0.08/GB-month
Fleettelemetry_params (94 days)Storage cost/monthExtra write rate
1,000 devices0.5–1 GB< $0.10~1 row/s
100,000 devices55–100 GB$4–8~110 rows/s
1,000,000 devices550 GB – 1 TB$44–80~1,100 rows/s (2–3 batches/s)
  • Main cost drivers. DB CPU for inserts, compression and queries, not storage. At 1M devices this belongs on the read-replica plan already in analytics.md §5.
  • Dev. One or two devices × 3 months is about 10–20 MB on the existing t4g.micro, so effectively $0.
  • No new AWS resources.
  • Cost levers, in order:
    1. Drop parameters nobody selects.
    2. Add a 15-minute tier for days older than 14 days.
    3. Shorter depth.

6. Phases​

PhaseScopeStatus
1Month/Year/Total: device-only get_analytics scope, total periodBuilt 2026-10-07
2internal/histparams catalog for Aotai and IP20Built 2026-10-07. Spec-evidence mappings not yet checked on hardware (§7).
3Migrations 0049–0053, param-history consumer, erasure, deviceadmin backfill-paramsBuilt 2026-10-07. Deploy early: history accrues only from this date (plus up to 72 h from the stream and 5 days from the backfill).
4get_param_catalog, get_param_history (Day, Week)Built 2026-10-07
5Client CSV export; integration guideBuilt 2026-10-07. The integration guide is written; export is client-side.

The existing get_analytics plant-scope behaviour, telemetry_15m and the energy rollup are unchanged.

7. Verification status and open items​

Passing (2026-10-07):

  • go vet ./... and the full go test ./... suite.
  • The race detector on every changed package.
  • Postgres integration tests on a fresh TimescaleDB (npm run test:db):
    • migrations 0001–0053 apply cleanly from empty
    • TestParamHistory_StoreAndRead: batched insert, duplicate, revoked and unknown loggers skipped, Day readings, Week mean versus last
    • TestAnalyticsReader_DeviceScopeAndYearTotals
    • TestErasureRemovesParameterHistory: history older than raw telemetry erased; a late row swept by FinishErasure
    • every existing storage, erasure and gateway database test
  • Catalog: resolution against the specs, shape, variant support, extraction. The migration's columns match the catalog.
  • Consumer: batching, skip/ack, transient left unacked, a permanent failure isolated to its row.
  • Gateway: catalog, Day and Week ranges, Monday–Sunday, the 3-month edge, validation, unsupported parameters, no database, and a bounds-checked series (a short store result once panicked the handler).
  • Local dev stack:
    • migrations applied on start
    • persistence-worker-param-history created and replayed the stream with no redeliveries
    • it keeps pace with live readings, alongside the raw-telemetry consumer

Open:

  1. Confirm stored values in local dev. On a fresh install the backfill reported 0 rows added, which is consistent with the consumer's replay having stored them already. Comparing raw readings with history rows per device settles it (§8, "Check that history is being stored").
  2. Deploy to AWS and follow §8 there.
  3. Hardware check of the spec mappings. Compare each against the inverter's own screen on the bench Aotai and IP20, starting with the defaults (PV voltages and currents, grid voltage and frequency, battery voltage). For IP20, also check which of each duplicated register is right. The flat object's bare name is the lowest address: pv1_voltage is read from 150, not 624 or 1174.
  4. Read-only measurements on dev_telemetry_db, each needing explicit approval:
    • Raw row size, to calibrate §5: SELECT avg(pg_column_size(readings)) FROM telemetry WHERE time > now() - interval '1 hour';
    • TimescaleDB version, to confirm inserts into compressed chunks (≥ 2.11) for late redelivery: SELECT extversion FROM pg_extension WHERE extname = 'timescaledb';
  5. After a week on dev, measure the real compressed size of telemetry_params and replace §5's estimates.

8. Operating it​

Rolling it out (once per environment)​

  1. Deploy the build.
    • Locally: npm run dev:stop && npm run dev.
    • On AWS: npm run deploy. Never a bare cdk deploy; see the repo CLAUDE.md.
    • persistence-worker (or tcpserver) applies migrations 0049–0053 when it starts. If they fail, it exits with failed to connect to postgres / run migrations. That stops all telemetry storage, so treat it as an incident.
  2. Check the consumer started. persistence-worker logs durable consumer ready with consumer: persistence-worker-param-history. action is created on the first start and unchanged after that. A created on any later start means the consumer was lost and the stream is being replayed. That's harmless, because inserts are idempotent.
  3. Backfill the raw window: npm run device -- backfill-params --yes locally. Against AWS, use go run ./cmd/deviceadmin backfill-params --yes through the SSM tunnel, as for any deviceadmin command (see the server page, "Against the deployed dev database"). It reads the 5 days of raw telemetry and inserts what isn't already there. Rows the consumer stored already are kept, so "added 0" right after a replay is normal.

Check that history is being stored​

  • Consumer state. Pending should be 0, or small and falling, with no steady redeliveries. Read it with nats consumer info TELEMETRY persistence-worker-param-history, or from a small nats.go js.ConsumerInfo call.

  • Rows versus raw readings. Run this read-only query; it needs approval when an agent runs it. Each device's with_history should equal raw_readings:

    SELECT t.device_id, d.logger_id, d.model, d.status, count(*) AS raw_readings, count(p.time) AS with_history
    FROM telemetry t
    LEFT JOIN devices d ON d.id = t.device_id
    LEFT JOIN telemetry_params p ON p.device_id = t.device_id AND p.time = t.time
    WHERE t.time >= now() - interval '5 days' AND t.cadence = 'default'
    GROUP BY t.device_id, d.logger_id, d.model, d.status;

    Fewer history rows than readings means one of three things: the device is revoked (skipped on purpose), its model has no parameter map (no current model; the IP20 3K6/5K has one since 2026-11-23), or the consumer is behind or failing (check its log).

  • End to end. Open the app's Historical Data screen for a device, or send get_param_catalog and get_param_history over the WebSocket. Step by step: integration guide.

Troubleshooting​

SymptomCauseFix
param_history reply with code: "unavailable", "not available yet on this server"Migrations 0049–0053 not applied on this databaseStart persistence-worker or tcpserver from the new build
backfill-params says "no telemetry_params table yet"SameSame, then re-run the backfill
Chart empty for a past day, unavailable: PERIOD_OUTSIDE_RETENTIONThe date is more than 3 months agoExpected (H1)
Chart empty for a recent day, no errorNothing stored for it: history starts at the rollout (plus the 72 h stream replay and 5-day backfill), or the device was offlineCheck the stored-history query above
A parameter always 0 with no reasonThe model has the register but this device's variant or firmware doesn't fill it, or the Aotai variant isn't known yet (variant: "")Compare with the live telemetry reading. If the device never sends it, take the mapping out
WARN param history consumer is behindThe consumer is slower than ingest, or the database is strugglingIt has until the stream's 72 h max age before readings are lost. Check database health and worker errors
ERROR param history row can never be stored, discarding itOne row failed permanently (schema drift, a value out of range)Its history is lost; raw telemetry is unaffected. Look at the error and fix the mapping or migration

Changing the catalog​

  • Adding a parameter:
    1. Add it to histparams.Params and its sources in sources.go.
    2. Add a new migration with a nullable ALTER TABLE telemetry_params ADD COLUMN <key> REAL. TestColumnsMatchCatalog compares the catalog with migration 0049 only, so update it to include the new migration's columns.
    3. History for it starts from that deploy.
  • Fixing a mapping applies to new rows only. Stored values are never rewritten, and backfill-params skips any reading whose row already exists (ON CONFLICT DO NOTHING), so it cannot repair them either.
  • Never rename or drop a parameter key. Clients and stored history depend on it. Stop mapping it instead.