Commit cf9cf72
Set unit_class on the imported statistics metadata
Home Assistant 2026.9 logs a frame warning when async_import_statistics is
called without unit_class, and the recorder stops accepting metadata without
the key in 2026.11. Derive it from STATISTIC_UNIT_TO_UNIT_CONVERTER the way
the recorder derives it, and skip the key on cores that predate it, so the
2024.11 floor in hacs.json still holds.
Measured on the ha-dev instance (Home Assistant 2026.9, podman container
ha-dev on nix1): before the change the metadata was accepted and the warning
fired; after it the metadata carries unit_class 'mass' for a kg sensor, no
warning appears, and the two hourly rows land in statistics_meta/statistics
with min 80.0, max 81.0, mean 80.5 at 08:00 UTC and 79.5/79.5/79.5 at 09:00.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 573b693 commit cf9cf72
1 file changed
Lines changed: 25 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | 23 | | |
29 | 24 | | |
30 | 25 | | |
| |||
33 | 28 | | |
34 | 29 | | |
35 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
36 | 50 | | |
37 | 51 | | |
38 | 52 | | |
| |||
66 | 80 | | |
67 | 81 | | |
68 | 82 | | |
69 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
70 | 86 | | |
71 | 87 | | |
72 | 88 | | |
| |||
79 | 95 | | |
80 | 96 | | |
81 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
82 | 101 | | |
83 | 102 | | |
84 | 103 | | |
| |||
0 commit comments