fix: lower MAX_AMPS to 14 for residential single-phase circuits
test / test (push) Has been cancelled

The hardcoded 16A ceiling was too high for a 14A circuit breaker.
Lowered the constant; tests updated accordingly. Making MAX_AMPS
configurable per install is a v0.1.3 follow-up — for now, anyone with
a different circuit rating will need to fork and edit the constant.
This commit is contained in:
naps62
2026-05-27 21:11:35 +00:00
parent 4c45620a3c
commit 34a01b0777
4 changed files with 12 additions and 7 deletions
+5
View File
@@ -1,5 +1,10 @@
# Changelog
## [0.1.2] - 2026-05-27
### Changed
- `MAX_AMPS` lowered from 16 to 14 to fit single-phase 14 A residential circuits. (Hardware-specific; making this configurable per install is on the v0.1.3 follow-up list.)
## [0.1.1] - 2026-05-27
### Fixed
@@ -98,7 +98,7 @@ def pick_submode(
# Defaults used internally; the coordinator passes config-driven values via Snapshot
# extensions in a later task. For v0.1 these are constants.
MIN_AMPS = 5
MAX_AMPS = 16
MAX_AMPS = 14
VOLTAGE = 230
DINNER_AMPS = 6
MAX_PLAUSIBLE_EV_W = 20_000 # anything above this is sensor glitch
+5 -5
View File
@@ -137,14 +137,14 @@ def test_force_min(base_snapshot: Snapshot) -> None:
def test_force_max_from_off(base_snapshot: Snapshot) -> None:
s = dataclasses.replace(base_snapshot, mode=Mode.FORCE_MAX, last_desired_amps=0)
d = compute_decision(s)
assert d.desired_amps == 16
assert d.desired_amps == 14
assert d.write_action is WriteAction.TURN_ON_AND_SET
def test_force_max_from_charging(base_snapshot: Snapshot) -> None:
s = dataclasses.replace(base_snapshot, mode=Mode.FORCE_MAX, last_desired_amps=10)
d = compute_decision(s)
assert d.desired_amps == 16
assert d.desired_amps == 14
assert d.write_action is WriteAction.SET_AMPS
@@ -198,7 +198,7 @@ def test_night_below_target_charges_at_max(base_snapshot: Snapshot) -> None:
last_desired_amps=None,
)
d = compute_decision(s)
assert d.desired_amps == 16
assert d.desired_amps == 14
assert d.sub_mode is SubMode.NIGHT
assert d.write_action is WriteAction.TURN_ON_AND_SET
@@ -210,7 +210,7 @@ def test_night_at_target_stops(base_snapshot: Snapshot) -> None:
now=datetime(2026, 5, 27, 23, 0, tzinfo=UTC),
ev_soc=80.0,
target_night_soc=80.0,
last_desired_amps=16,
last_desired_amps=14,
)
d = compute_decision(s)
assert d.desired_amps == 0
@@ -343,7 +343,7 @@ def test_solar_clamps_to_max_amps(base_snapshot: Snapshot) -> None:
target_day_soc=80.0,
)
d = compute_decision(s)
assert d.desired_amps == 16
assert d.desired_amps == 14
def test_negative_ev_consumption_treated_as_zero(base_snapshot: Snapshot) -> None:
+1 -1
View File
@@ -351,4 +351,4 @@ async def test_service_call_failure_does_not_crash_tick(hass: HomeAssistant) ->
assert result is not None
assert result.sub_mode is SubMode.FORCE_MAX
# Service-call failure is logged, not propagated; coordinator still records intent
assert coord._last_desired_amps == 16
assert coord._last_desired_amps == 14