docs(hass): CSG 模板/面板修复记录 — availability 硬化 (W1N-239)、off-by-one + 新传感器 (W1N-241)、gauge 阶梯对齐 + 年度统计 (W1N-240)
- hosts/hass.windy.lan.md: csg_sensors 三次变更记录 + 季节性 gauge 切换已知事项 (11-01/5-01) - runbooks/home-assistant-maintenance.md: float(0) fake-zero follow-up 标记已解决
This commit is contained in:
@@ -228,6 +228,54 @@ cost/ladder sensors can stay `unknown` because CSG
|
|||||||
dashboard uses template ladder/cost entities instead. Do not change
|
dashboard uses template ladder/cost entities instead. Do not change
|
||||||
`templates/csg_sensors.yaml` or the 电力监控 dashboard for an install.
|
`templates/csg_sensors.yaml` or the 电力监控 dashboard for an install.
|
||||||
|
|
||||||
|
**`templates/csg_sensors.yaml` hardened 2026-08-29 (W1N-239):** added
|
||||||
|
`availability` templates to all 12 `csg_*` sensors (numeric sensors can't
|
||||||
|
render `unknown`/`unavailable` in `state`; availability suppresses
|
||||||
|
rendering instead — native CSG down ⇒ derived sensors show `unavailable`,
|
||||||
|
no more fake zeros / "一档" / `0%`). `csg_yesterday_kwh` now falls back to
|
||||||
|
`last_month_by_day`'s last entry when `this_month_by_day` is empty (month
|
||||||
|
start); ladder constants (`t1/t2/p1/p2/p3`) deduped into per-block
|
||||||
|
`variables:` (Block B + Block D); `csg_mom_change` parses `date`
|
||||||
|
defensively. Backup:
|
||||||
|
`/homeassistant/.csg-backups/csg_sensors.yaml.bak-20260829-w1n239`.
|
||||||
|
**Verified:** `ha core check` OK; Core restart required (trigger-based
|
||||||
|
template blocks don't settle on `template.reload` — W1N-114 precedent);
|
||||||
|
post-restart all 12 entities numeric & consistent (302.47 kWh→180.28 元,
|
||||||
|
324.03 kWh→194.06 元, mom_change -3.6%, yesterday 7.66 kWh/2026-08-28),
|
||||||
|
no template errors in Core logs.
|
||||||
|
|
||||||
|
**`csg_sensors.yaml` off-by-one fixed 2026-08-29 (W1N-241):** CSG data
|
||||||
|
lags 1 day (`sum(this_month_by_day)` == `this_month_total_usage`, data
|
||||||
|
stops at yesterday), but templates used `now().day` as "days elapsed" →
|
||||||
|
`csg_predicted_usage` underestimated ~1 daily avg (~3%) and
|
||||||
|
`csg_mom_change` compared this-month 28 days vs last-month 29 days
|
||||||
|
(-3.6% vs true -0.3%). Both now derive the day number from
|
||||||
|
`this_month_by_day[-1].date` (fallback `now().day` when empty). Added
|
||||||
|
`sensor.csg_this_month_daily_avg` (month-to-date avg, 302.47/28=10.8) and
|
||||||
|
`sensor.csg_prediction_progress` (usage/predicted %, 90.3) in Block C
|
||||||
|
(trigger adds `csg_predicted_usage`). Backup:
|
||||||
|
`/homeassistant/.csg-backups/csg_sensors.yaml.bak-20260829-w1n241`.
|
||||||
|
**Verified (8/29):** predicted 324.03→334.81, mom_change -3.6→-0.3,
|
||||||
|
daily_avg 10.8, progress 90.3, predicted_cost 194.06→200.94 (334.81 kWh
|
||||||
|
ladder), ladder cost 180.28 unchanged, `ha core check` OK after restart,
|
||||||
|
no template errors; 14 csg_* entities total.
|
||||||
|
|
||||||
|
**电力监控面板(`lovelace.dashboard_unknown` / view `power-monitor`)
|
||||||
|
updated 2026-08-29 (W1N-240):** 「本月累计」gauge 对齐夏季阶梯:
|
||||||
|
`max:650`、segments `0/260/600`(绿/橙/红 = 一/二/三档;冬季 11-01 需切
|
||||||
|
`max:450`、`0/200/400` — **seasonal switch point**,见下文)。「📊 统计
|
||||||
|
数据」卡新增本年/去年 4 行(原生传感器,口径标注「电费(账单)」、本年
|
||||||
|
「(至今)」);面板共引用 18 个实体。改前备份:
|
||||||
|
`/homeassistant/.lovelace-backups/dashboard-unknown-power-monitor-20260829-204845.json`
|
||||||
|
(改法:WS `lovelace/config/save`,参数 `url_path: dashboard-unknown` +
|
||||||
|
`config`;勿直改 `.storage/`)。验证:WS 读回 18 实体 diff ✓、gauge
|
||||||
|
配置一致 ✓、URL `http://hass.windy.lan:8123/dashboard-unknown/power-monitor`。
|
||||||
|
|
||||||
|
> **Seasonal gauge switch (W1N-240 已知事项):** 每年 **11-01** 把
|
||||||
|
> `power-monitor` 视图「本月累计」gauge 切到冬季 `max:450` /
|
||||||
|
> `0/200/400`,**5-01** 切回夏季 `max:650` / `0/260/600`(与模板
|
||||||
|
> `now().month` 季节逻辑对齐;模板常量在 Block B/D `variables`)。
|
||||||
|
|
||||||
Home PPPoE IPv4 to CSG is still blackholed (`curl -4` to `218.19.148.218:443`
|
Home PPPoE IPv4 to CSG is still blackholed (`curl -4` to `218.19.148.218:443`
|
||||||
times out). `end0` IPv6 is enabled (`ipv6.method: auto`); from HA,
|
times out). `end0` IPv6 is enabled (`ipv6.method: auto`); from HA,
|
||||||
`curl -6 https://95598.csg.cn` returns HTTP 200 via `240e:f9:8060::1:16`.
|
`curl -6 https://95598.csg.cn` returns HTTP 200 via `240e:f9:8060::1:16`.
|
||||||
|
|||||||
@@ -284,8 +284,10 @@ print(urllib.request.urlopen(req, timeout=60).status)
|
|||||||
|
|
||||||
7. **Do not edit the dashboard or `templates/csg_sensors.yaml` for an
|
7. **Do not edit the dashboard or `templates/csg_sensors.yaml` for an
|
||||||
install.** Entity IDs did not change across v1.3.0/v1.3.1/v1.3.2.
|
install.** Entity IDs did not change across v1.3.0/v1.3.1/v1.3.2.
|
||||||
Template `| float(0)` turns native `unavailable` into fake zeros; that
|
(The old `| float(0)` fake-zero follow-up was resolved 2026-08-29 by
|
||||||
is a follow-up, not part of the zip install.
|
W1N-239: template sensors now carry `availability` templates and show
|
||||||
|
`unavailable` instead of fake zeros when native CSG sensors are down.
|
||||||
|
Template edits go through that issue, not the install path.)
|
||||||
|
|
||||||
#### Verify (CSG, after v1.3.2 / W1N-118)
|
#### Verify (CSG, after v1.3.2 / W1N-118)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user