fix: watts_to_amps round() misto int() — 11 kW = 16 A (ne 15 A / -6%)
All checks were successful
CI and deploy / migration-check (push) Successful in 16s
CI and deploy / deploy (push) Has been skipped

11000 W / (3x230) = 15.94 A; int() useklo na 15 A (~10.35 kW), round da
spravnych 16 A (~11 kW). Strop 32 A drzi horni mez. 74 control testu zelenych.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dusan Vojacek
2026-06-14 17:42:30 +02:00
parent f726188ec9
commit 1ef8630302

View File

@@ -146,9 +146,11 @@ def _deye_reg178_verify_with_double_read(
def watts_to_amps(power_w: int | None, phases: int = 3, voltage: int = 230) -> int:
# round(), NE int(): 11 kW / (3×230) = 15.94 A → int useklo na 15 A (~10.35 kW,
# 6 % výkonu); round dá správných 16 A (~11 kW). Strop 32 A drží horní mez.
if not power_w or power_w <= 0:
return 0
return min(32, max(0, int(power_w / (phases * voltage))))
return min(32, max(0, round(power_w / (phases * voltage))))
def battery_watts_to_amps(power_w: int, max_amps: int) -> int: