docs(hass,pgdb): timescale-plotly-card chart stack — reader+card install, sensor_minute pipeline, Quick dashboard

- reader timescale_database_reader v1.1.0 (bb8776a) + card timescale-plotly-card
  2.2.0 (217961d), manual installs; config entry, Lovelace resource id recorded
- pgdb scribe: sensor_minute_aggregate cagg + sensor_minute hypertable + jobs
  1005/1006/1007; states_raw 3-month retention/compression statements deliberately
  skipped (permanent archive per host doc)
- sensor_minute_refresh local patch ELSE 0 → ELSE NULL (unavailable-minute zeros
  poison diff-mode energy charts) + one-time cleanup (505 head rows, 26 impossible
  zeros); re-apply after re-running upstream 02 SQL
- Quick dashboard: 5 chart cards via WS lovelace/config/save; documented section
  column_span (absent → span 1) vs card grid_options sizing rules
This commit is contained in:
windyboy
2026-08-29 15:54:40 +08:00
parent bc0a86245d
commit 8c73d1f894
2 changed files with 51 additions and 0 deletions
+49
View File
@@ -351,6 +351,55 @@ deployed 2026-08-18 from `216cc99` (backup
- Recorder stays external-Postgres with `purge_keep_days: 30` for daily UI
history; Scribe is the permanent archive.
### Timescale Plotly card + database reader (verified 2026-08-29)
Chart stack over the Scribe TimescaleDB archive. Upstream pair (no HACS;
manual copies): reader `remmob/timescale_database_reader` **v1.1.0** (main
`bb8776a`) + card `remmob/timescale-plotly-card` **2.2.0** (main `217961d`).
- **Reader integration**: `/homeassistant/custom_components/timescale_database_reader/`.
Config entry `01M165P77QT1FQEAVPNZHDT82W` ("Scribe", `source: user`): connects
`hass@192.168.55.15:5432/scribe` (credentials = `secrets.yaml` `scribe_url`),
`table: sensor_minute`. Exposes no entities/services — it serves WS command
`timescale/query` (window ≤ 365 d, ≤ 50 000 rows, `downsample` bucket seconds).
Benign startup warning `Error executing test query: column "time" does not
exist`: the self-test SQL assumes the LTSS column name; the scribe table uses
`minute` — real queries work (verified: 70 rows for a live power sensor).
- **Card**: `/homeassistant/www/community/timescale-plotly-card/timescale-plotly-card.js`
(root-owned, same convention as HACS dirs). Lovelace resource (storage)
id `2e360d17b5aa4ce59c2fd13c43b51215`
`/hacsfiles/timescale-plotly-card/timescale-plotly-card.js`, type `module`.
Card config matches the entry by `database: scribe` (name from the reader
entry). Updates: replace the file, resource URL unchanged — browsers need a
hard refresh or a bumped `?v=` query on the resource URL.
- **pgdb side** (`sensor_minute_aggregate` cagg + `sensor_minute` hypertable +
every-minute refresh job): see [hosts/pgdb.md](pgdb.md) § Databases.
- **Agent-side HA WebSocket without a long-lived token** (verified 2026-08-29):
connect `ws://supervisor/core/websocket` with header
`Authorization: Bearer $SUPERVISOR_TOKEN`, then send
`{"type":"auth","access_token":"$SUPERVISOR_TOKEN"}` — the Supervisor proxy
swaps it for a core token (works as the internal Supervisor admin user). Note
`lovelace/resources/create` in HA 2026.8 takes `res_type` (NOT
`resource_type`).
- Scribe stores numeric sensor values in `states_raw.value` with `state` NULL,
so `sensor_minute.state` shows `'0'` for numeric sensors; the card plots
`avg_state` (from `value`) — expected, not a bug.
- **Quick 仪表盘(`dashboard-quick`)图表套件**2026-08-29,经 WS
`lovelace/config/save` 写入):5 张 timescale 卡——大功率电器/常驻负载
功率(按量级拆两张图,避免 1100 W 尖峰压扁 <70 W 基线)、按插座用电量
`energy_mode` + cumulative/diff,数据质量前提见 pgdb 的 refresh 过程补丁)、
室内外温湿度(温度左轴/湿度右轴,4 位置同色配对)、人体感应活动状态
3 个 `motion_state`banded `state_map` none/small/medium/large → 0-11)。
布局:全部分区显式 `column_span: 4`(视图 `type: sections` + `max_columns: 4`),
灯区 4 张控制卡横排一行。**分区/卡片是两套尺寸键,不可混用**:
分区宽 = `column_span``hui-sections-view.ts` 缺省按 1 列渲染,绝不省略);
卡片宽 = `grid_options: {columns: <n|"full">}``hui-card.ts` 只读
`config.grid_options`,写在卡片上的 `column_span` 被静默忽略;缺省 12 列,
分区内格 = 12 × 分区 span,故 span-4 分区里缺省卡片只有 1/4 宽)。另外
图表卡固定外壳(标题/时间按钮/状态行 ≈125px)使整卡最低 ~300px,与矮
控制区并排必然留白,故不做半宽并排。
修改前备份:`/homeassistant/.lovelace-backups/dashboard-quick-*.json`
## Known issues
**Bluetooth hci0 instability — RTL8821CS (verified 2026-08-13, W1N-74):**