Repository navigation
Commit 8e3d72b
fix(1P): ac power scaling (#123)
* fix(1P): scale AC power registers by register 54 (AC power ratio)
Per the V119 protocol, the AC power registers 167-169 (grid), 170-172
(external CT) and 176-178 (load) are reported in units of register 54
(1W or 10W per LSB). Read register 54 as an "AC Power Ratio" sensor and
multiply those power sensors by it, so values match the inverter display
(e.g. External CT Power 875 -> 8750 when the ratio is 10). Falls back to
the raw value while the ratio is unread.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* refactor(1P): only scale AC power on known ratio, hoist lambda into substitution
Per PR #123 review: guard the register 54 multiply so it only applies on a
verified 10W/LSB value and passes raw watts through otherwise. Confirmed on
hardware: SG02 10kW reports ratio 10 (10W units), SG04 6kW reports 0 (1W
units). NaN == 10.0f is false, so the not-yet-read state needs no isnan check.
Lambda hoisted into a substitution following the tou.yaml pattern.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(1P): mark AC power ratio register 54 as internal
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent cbb2f1d commit 8e3d72b
2 files changed
Lines changed: 47 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
15 | 21 | | |
16 | 22 | | |
17 | 23 | | |
| |||
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
24 | 46 | | |
25 | 47 | | |
26 | 48 | | |
27 | 49 | | |
28 | 50 | | |
| 51 | + | |
| 52 | + | |
29 | 53 | | |
30 | 54 | | |
31 | 55 | | |
| |||
38 | 62 | | |
39 | 63 | | |
40 | 64 | | |
| 65 | + | |
| 66 | + | |
41 | 67 | | |
42 | 68 | | |
43 | 69 | | |
| |||
50 | 76 | | |
51 | 77 | | |
52 | 78 | | |
| 79 | + | |
| 80 | + | |
53 | 81 | | |
54 | 82 | | |
55 | 83 | | |
| |||
208 | 236 | | |
209 | 237 | | |
210 | 238 | | |
| 239 | + | |
| 240 | + | |
211 | 241 | | |
212 | 242 | | |
213 | 243 | | |
| |||
219 | 249 | | |
220 | 250 | | |
221 | 251 | | |
| 252 | + | |
| 253 | + | |
222 | 254 | | |
223 | 255 | | |
224 | 256 | | |
| |||
230 | 262 | | |
231 | 263 | | |
232 | 264 | | |
| 265 | + | |
| 266 | + | |
233 | 267 | | |
234 | 268 | | |
235 | 269 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| |||
43 | 50 | | |
44 | 51 | | |
45 | 52 | | |
| 53 | + | |
| 54 | + | |
46 | 55 | | |
47 | 56 | | |
48 | 57 | | |
| |||
55 | 64 | | |
56 | 65 | | |
57 | 66 | | |
| 67 | + | |
| 68 | + | |
58 | 69 | | |
59 | 70 | | |
60 | 71 | | |
| |||
67 | 78 | | |
68 | 79 | | |
69 | 80 | | |
| 81 | + | |
| 82 | + | |
70 | 83 | | |
71 | 84 | | |
72 | 85 | | |
| |||
0 commit comments