30 Commits

Author SHA1 Message Date
naps62 7d0be3c70c feat: unit-aware power sensors + ceil() for max solar self-consumption
test / test (push) Has been cancelled
Two related fixes for v0.1.3:

1. _read_power_w() reads each power sensor's unit_of_measurement and
   converts kW to W. Before this, sensors reporting in kW (Tesla
   integration's leomobile_charger_power = "1" kW) were treated as raw
   watts, causing the leftover calculation to undercount by ~1000×.
   In practice the algorithm sent the EV charge rate that matched
   "what's exporting NOW" instead of "what's available if EV pulled
   everything" — leaving ~1 kW of solar exported instead of routed to
   the car.

2. round() → math.ceil() on the amp computation. Trade-off: up to
   ~VOLTAGE watts of grid import per tick, in exchange for zero solar
   export. Maximizes PV self-consumption, accepts small grid cost as
   rounding noise.

Tests added: kW conversion round-trip; ceil rounds up partial amps.
All 57 pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
v0.1.3
2026-05-28 15:47:31 +00:00
naps62 d73b4ec7a3 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.
v0.1.2
2026-05-27 21:11:50 +00:00
naps62 4c45620a3c chore: bump to v0.1.1
test / test (push) Has been cancelled
v0.1.1
2026-05-27 16:51:05 +00:00
naps62 fcf12eeb2b fix: service-call failures are logged, not fatal
If the EV's service rejected a write (e.g. Tesla integration raising
'Command was unsuccessful: is_charging' when we redundantly call
switch.turn_on while charging already running), the exception used to
propagate up through _async_update_data, killing the whole coordinator
update and putting the integration into setup_retry indefinitely.

Wrap service calls in a _safe_service_call helper that catches and
logs at WARNING; the coordinator still returns a valid Decision so
entities populate. The next tick reconciles naturally.
2026-05-27 16:51:03 +00:00
naps62 a642631058 fix: Mode.OFF no longer triggers redundant turn_off writes
test / test (push) Has been cancelled
The gate-reset condition was matching Mode.OFF (sub_mode=DISABLED,
write_action=NONE) and clearing last_desired_amps each tick, causing
the next tick to re-issue switch.turn_off. Disambiguate by checking
desired_amps is None — only the true gate-closure path returns None.

Also removes now-unused SubMode import from coordinator.py.
v0.1.0
2026-05-27 16:06:34 +00:00
naps62 a6336d6f36 docs: README and CHANGELOG for v0.1.0 2026-05-27 15:54:12 +00:00
naps62 3941cca46c ci: ruff + mypy + pytest on push/PR 2026-05-27 15:53:03 +00:00
naps62 58caba43f7 feat: diagnostics dump 2026-05-27 15:52:15 +00:00
naps62 30a32eec0e chore: ruff cosmetic fix on test comment alignment 2026-05-27 15:51:28 +00:00
naps62 657ed2dfe4 feat: config flow with grid-signal validators
Adds ConfigFlow with async_step_user, three validators (missing grid signal,
mutual exclusivity, EV draw plausibility), strings.json + translations/en.json,
and three passing tests. Adds enable_custom_integrations autouse fixture to
conftest.py to allow HA to discover the custom integration during tests.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:51:13 +00:00
naps62 4bef8f2289 feat: integration setup, platform wiring, and event-triggered fast ticks
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:47:52 +00:00
naps62 0f3966bb27 feat: sensor and binary_sensor platforms
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:46:20 +00:00
naps62 8ae6b745dc feat: select/switch/time platforms
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:44:37 +00:00
naps62 6d9d71dd18 feat: number platform for day/night SOC targets
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:42:53 +00:00
naps62 9f833759a0 feat: coordinator safety fallback on stale required sensors
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:41:27 +00:00
naps62 222d9ed57e feat: coordinator main tick with gate state reset
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:38:53 +00:00
naps62 42ad5d6d24 feat: coordinator applies decisions via service calls
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 15:37:01 +00:00
naps62 e613cc823b feat: coordinator reads Snapshot from HA state
Add _build_snapshot and helper methods (_read_float, _read_bool,
_read_at_home, _read_sun_state, _read_net_grid) to EVSolarChargerCoordinator
so it can assemble a full Snapshot from live HA entity states.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:34:06 +00:00
naps62 7412c4be1f feat: coordinator skeleton
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:31:45 +00:00
naps62 4cf5afcc0f feat: safety-fallback decision helper
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:29:35 +00:00
naps62 244bb9e2da feat: sanitize anomalous EV consumption inputs 2026-05-27 15:27:36 +00:00
naps62 c2afe026a3 feat: solar sub-mode forward calculation with target floor
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:25:51 +00:00
naps62 de77bf79b4 feat: night sub-mode with target SOC gate 2026-05-27 15:23:50 +00:00
naps62 d20930a91e feat: dinner sub-mode hard cap 2026-05-27 15:22:23 +00:00
naps62 d325f43f7e feat: compute_decision gates and force-mode overrides
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:20:33 +00:00
naps62 bc7bd7e86e feat: implement pick_submode resolver
Pure function resolving sub-mode from time-of-day and sun state; 9
parametrized test cases covering all boundary conditions.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:18:06 +00:00
naps62 8a6b0037d5 feat: add algorithm dataclasses and enums
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 15:13:46 +00:00
naps62 ac9dd2137c feat: add constants module 2026-05-27 15:10:17 +00:00
naps62 f8b810a9d9 feat: add manifest and hacs config 2026-05-27 15:08:23 +00:00
naps62 5a8ba8af88 chore: bootstrap repo skeleton 2026-05-27 15:05:47 +00:00