Commit Graph

50 Commits

Author SHA1 Message Date
Dusan Vojacek
daf7ed4d4b fix(control): reg 108 v PV_SURPLUS sleduje charge intent (BA81 nenabíjelo levné ráno)
deye_battery_charge_discharge_amps: v PASSIVE+PV_SURPLUS reg 108 = max když plán
chce nabíjet (bat_w>0) místo tvrdé 0; baterka nabere co zvládne, přebytek nad
nabíjecí rychlost do sítě. + kalibrace: SoC u maxima → dojet na 100% (BMS). Sell
beze změny. Vědomě přepsán test starého chování. 365 passed. Všechny Deye lokality.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 16:32:01 +02:00
Dusan Vojacek
1ef8630302 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>
2026-06-14 17:42:30 +02:00
Dusan Vojacek
8452b34b25 Merge branch 'fix/ev-teltocharge-reg15-and-session-visibility' into dev
Some checks failed
CI and deploy / migration-check (push) Failing after 7m26s
CI and deploy / deploy (push) Has been skipped
# Conflicts:
#	docs/planning-changelog.md
2026-06-13 22:41:14 +02:00
Dusan Vojacek
521a3653d3 Faze 0A: battery guard carve-out — neblokovat import na nabiti pri zaporne cene
_apply_export_plan_guard / _build_setpoints: kdyz slot CHARGE / importuje na
nabiti baterie (grid_sp>0 & bat>0), guard vrati sp beze zmeny a export_ban se
nenastavi. Opravuje, ze se baterie nedobila v zapornych cenach (CHARGE+17kW
prekloplen na PASSIVE -> Deye nenabijel ze site). Diagnoza: agent a599eecc.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 22:40:18 +02:00
Dusan Vojacek
54288ee2fd fix(modbus): reg 15 re-asert kazdy tick + per-charger failsafe (BUG1)
Zivy incident home-01 (TeltoCharge .16): od ~22:45 UTC 12.6. nevznikl zadny
telto journal radek (ani failed), auto jelo failsafe 8 A misto planovanych 0 A.

Root cause: reg 15 (amps) byl write-on-change proti journalu
(fn_modbus_device_state_map). Jakmile mel reg 15 radek "0 verified" a plan
dal chtel 0, NIKDY nevznikl novy prikaz -- a TeltoCharge si po vypadku
komunikace sam prepsal reg 15 na failsafe (reg 20) BEZ journal radku. Verify
cte zpet jen 'written' radky, takze tichy drift 0 -> 8 A nikdo nevidel ani
neopravil.

- reg 15 (amps to use) se zapisuje VZDY (re-asert) -- volatilni ridici
  registr, ne EEPROM; drzi verify jobu cerstvy written radek -> drift se
  zachyti a hned opravi. _split_amps_and_watchdog odděluje 15 od 19/20.
- reg 19/20 (watchdog config, EEPROM) zustavaji write-on-change.
- per-charger failsafe/timeout: asset_ev_charger.watchdog_failsafe_a /
  watchdog_comm_timeout_s (V106; default 8 A / 300 s). "Zakaz nabijeni" =
  reg 15 = 0 (protokol rev 0.5 nema samostatny enable registr).
- testy test_ev_write_on_change.py; docs teltocharge + journal + data-model.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 22:03:11 +02:00
Dusan Vojacek
b08782525e fix(modbus): zadne vecne pending v journalu + flock timeout + EV poll backoff
Zivy incident home-01 (TeltoCharge .16): zapis 15/19-20 koncil failed
s prazdnym error_msg, nebo zustal trvale pending a zablokoval exportni ticky.

- _gateway_exclusive: neblokujici flock s deadline (EMS_MODBUS_FLOCK_TIMEOUT_S,
  default 20 s) -> GatewayLockTimeout misto starvation bez limitu
- execute_modbus_commands: invariant written/failed + neprazdny error_msg
  (str(e) or repr(e)); safety net pres BaseException (CancelledError, chyba DB);
  journal update mimo retry cyklus zarizeni; force_disconnect bez zamku brany
- telemetry poll_ev_chargers: po 3 selhanich backoff 5 min per (host,port,unit)
  - mrtvy unit_id drzi branu 4x8=32 s z kazde minuty
- testy backend/tests/test_modbus_execute_failsafe.py; docs
  modbus-command-journal.md (sekce Robustnost zapisu + konfigurace)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-13 00:17:04 +02:00
Dusan Vojacek
7decfebdbd TeltoCharge write-on-change: zápis jen při změně hodnoty (EEPROM wear)
Wallbox dostával zápisy 15/19/20 každý export tick (~8x/hod: control_export
:14,:29,:44,:59 + rolling replan */15 s exportem), protože drop-unchanged
stál na fn_modbus_last_verified_map — dokud verify čtení nedoběhlo/selhalo,
mapa byla prázdná a celá trojice se psala pořád dokola. write_ev_arrival_hold
navíc psal trojici nepodmíněně při každém píchnutí kabelu (docstring lhal).

- nová ems.fn_modbus_device_state_map (R__100): nejnovější řádek journalu
  per registr, hodnota jen pro written/verified; failed/mismatch => registr
  chybí => po výpadku se konfigurace obnoví jedním zápisem
- write_ev_setpoints + write_ev_arrival_hold filtrují přes tuto mapu:
  reg 15 jen při změně plánu, watchdog 19/20 jednou po startu/po výpadku
- verify job EV chargery ověřuje už dnes (fn_modbus_written_command_ids bez
  filtru asset_type); registry 15/19/20 jsou dle oficiálního protokolu R/W
- watchdog Telto sytí jakákoli validní komunikace vč. FC3 čtení telemetrie
  (60 s << 300 s) — periodické zápisy k udržení spojení nejsou potřeba,
  failsafe 8 A nastane jen při skutečném výpadku EMS
- testy: tests/test_ev_write_on_change.py (drop, setpoints, arrival hold)
- docs: modbus-registers-teltocharge.md (sekce Zápis už není "NEimplementováno",
  R/W tabulka, watchdog sémantika), modbus-command-journal.md (sekce EV
  wallbox), CLAUDE.md (fn_modbus_device_state_map)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 22:21:59 +02:00
Dusan Vojacek
5530253662 EV arrival hold: po detekci píchnutí okamžitě 0 A — nabíjení spouští až plán
All checks were successful
CI and deploy / migration-check (push) Successful in 28s
CI and deploy / deploy (push) Successful in 1m15s
TeltoCharge po připojení kabelu sám rozjede nabíjení svým defaultem; EMS ho
dosud dohnal až exportem setpointů (do 15 min). _on_ev_arrival nyní před
replanem zapíše přes journal telto_amps_to_use=0 (write_ev_arrival_hold),
replan+export vzápětí nastaví plánované ampéry. Watchdog (300 s → failsafe
8 A) zachován — výpadek EMS auto nenechá na 0 A.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 19:52:10 +02:00
Dusan Vojacek
dd3bd55c0e Fix reg 340: záporný buy+sell má přednost před úsvitovou výjimkou
All checks were successful
CI and deploy / migration-check (push) Successful in 13s
CI and deploy / deploy (push) Successful in 53s
Větev 'slabý úsvit (forecast<1500 W) → reg 340 neposílat' zastínila větev
'buy<0 a sell<0 + pole B → pv_a_allowed=0' — při hluboce záporných cenách
za úsvitu by se pole A nezavřelo. Prohozeno pořadí; opravuje pre-existing
fail test_neg_buy_and_sell_with_pv_b_forces_pv_a_off (293 passed, 4 xfail).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 15:19:10 +02:00
Dusan Vojacek
c7f595c587 HOTFIX BA81: export plan guard neodstavuje pole B při kladné vykupní ceně
Some checks failed
CI and deploy / deploy (push) Has been cancelled
CI and deploy / migration-check (push) Has been cancelled
_apply_export_plan_guard při export_mode=NONE (plán nabíjí baterii, neexportuje)
vynucoval _passive_no_export_guard s export_ban=True + deye_gen_cutoff_enabled=True
bez ohledu na cenu -> reg 178 bity 0-1=3 (MI cutoff) + reg 145=0 a mikroinvertory
(pole B) fyzicky stály i při sell +1.36 Kč (BA81 dnes: gen port ~0 W od 12:16Z,
SoC 64 %, stringy 4.2 kW do baterie). Tvrdý ban nově JEN při záporné vykupní;
při kladné guard dál drží PASSIVE/143=0/baterie nevybíjí do sítě, ale MI jedou
(absorbce do baterie, přetok se prodá). Plánový z_gen_cutoff se respektuje.

Pre-existing fail test_neg_buy_and_sell_with_pv_b_forces_pv_a_off padá i na main
(pv_a_allowed_w None != 0) — nesouvisí, řešit zvlášť.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 15:07:17 +02:00
Dusan Vojacek
0ed6f18e1a EV řízení: zápis Amps-to-use přes journal + watchdog + okamžitý replan po příjezdu
Some checks failed
CI and deploy / migration-check (push) Successful in 39s
CI and deploy / deploy (push) Failing after 9m55s
Bod 1 — write_ev_setpoints reálně (konec TODO stubu):
- reg 15 (0=stop, 6–32 A) z plánu přes _current_limit_for_charger; plná
  journal pipeline (create_modbus_commands → execute, verify job 2 min generic)
- watchdog reg 19=300 s + reg 20=8 A: výpadek EMS → wallbox po 5 min failsafe
  8 A (auto se přes noc nabije); drop-unchanged → zapisuje se jen při změně
- fn_modbus_last_verified_map: + p_asset_type (drop 2-arg; dosud hardcoded
  'inverter' — pro chargery vracela {})
- verify: SELF_SUSTAIN fallback explicitně jen pro asset_type='inverter' —
  mismatch wallboxu nesmí degradovat režim celé site
- journal register_name: mimo inverter platí jméno od volajícího

Bod 2 — telemetry_collector: přechod available→connected spustí fire-and-forget
run_rolling_replan(triggered_by=ev_arrival:<code>) + export_setpoints přes BG
pool — reakce na příjezd ~60 s místo až 15 min.

Bod 3 (Tesla API SoC) čeká na developer credentials.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-11 22:51:38 +02:00
Dusan Vojacek
0f7dc6ed94 Branch 4: BA81 GEN cutoff audit + exekuce při sell<0
Some checks failed
CI and deploy / migration-check (push) Failing after 14s
CI and deploy / deploy (push) Has been skipped
2026-06-06 22:36:27 +02:00
Dusan Vojacek
a03b45d4a9 oprava zbytecneho curtailu A
Some checks failed
CI and deploy / migration-check (push) Failing after 10s
CI and deploy / deploy (push) Has been skipped
2026-05-30 23:23:17 +02:00
Dusan Vojacek
a7dff75e58 Add export plan guard to block Deye export against plan.
Some checks failed
CI and deploy / migration-check (push) Failing after 39s
CI and deploy / deploy (push) Has been skipped
Force PASSIVE/no-export when sell is negative or export_mode is NONE,
and alert NEG_SELL_EXPORT in plan_actual_slot_guard when export still occurs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-29 00:14:52 +02:00
Dusan Vojacek
52e4b68789 ski battery charge u sell
Some checks failed
CI and deploy / migration-check (push) Failing after 26s
CI and deploy / deploy (push) Has been skipped
2026-05-28 23:22:57 +02:00
Dusan Vojacek
c6074e9c74 nastavitelny max sollar dle stridace (ulozeno v DB)
Some checks failed
CI and deploy / migration-check (push) Failing after 13s
CI and deploy / deploy (push) Has been skipped
2026-05-25 11:25:29 +02:00
Dusan Vojacek
e06f76b9ff uprava PV omeznovani
Some checks failed
CI and deploy / migration-check (push) Failing after 13s
CI and deploy / deploy (push) Has been skipped
2026-05-25 11:08:01 +02:00
Dusan Vojacek
eb425a26f2 narovnani spravneho rezimu - nastavenim charge A
Some checks failed
CI and deploy / migration-check (push) Failing after 12s
CI and deploy / deploy (push) Has been skipped
2026-05-21 10:23:53 +02:00
Dusan Vojacek
44a06b6288 fix ranniho neprodeje do site
Some checks failed
CI and deploy / migration-check (push) Failing after 42s
CI and deploy / deploy (push) Has been skipped
2026-05-21 10:02:19 +02:00
Dusan Vojacek
8a3a49806b dalsi pokus ladeni
Some checks failed
CI and deploy / migration-check (pull_request) Failing after 17s
CI and deploy / deploy (pull_request) Has been skipped
2026-05-04 20:11:50 +02:00
Dusan Vojacek
b35f292295 fix chargedischarge A
Some checks failed
CI and deploy / migration-check (pull_request) Failing after 25s
CI and deploy / deploy (pull_request) Has been skipped
2026-05-04 19:37:42 +02:00
Dusan Vojacek
bcb05d4896 tuning palnneru 2026-05-04 19:04:48 +02:00
Dusan Vojacek
e8eb867a2a refactor export limit semantics
Some checks failed
CI and deploy / migration-check (pull_request) Failing after 15s
CI and deploy / deploy (pull_request) Has been skipped
2026-05-03 22:24:35 +02:00
Dusan Vojacek
349a15e96a update control package facade docs
Some checks failed
CI and deploy / migration-check (pull_request) Failing after 12s
CI and deploy / deploy (pull_request) Has been skipped
2026-05-02 19:57:23 +02:00
Dusan Vojacek
6129677756 refactor control export orchestrator 2026-05-02 19:56:32 +02:00
Dusan Vojacek
6cacf523a2 refactor deye inverter control 2026-05-02 19:54:54 +02:00
Dusan Vojacek
44cd7f986a refactor modbus verify workflow 2026-05-02 19:51:41 +02:00
Dusan Vojacek
53288d130a refactor control output writers 2026-05-02 19:47:12 +02:00
Dusan Vojacek
abe4255f88 refactor modbus command journal 2026-05-02 19:45:22 +02:00
Dusan Vojacek
55ccf06627 refactor control repository access 2026-05-02 19:42:58 +02:00
Dusan Vojacek
0ca1bed0fd refactor control setpoint calculations 2026-05-02 19:40:16 +02:00
Dusan Vojacek
6d6341cde8 refactor control exporter helpers 2026-05-02 19:35:41 +02:00
Dusan Vojacek
b20cb6e0f9 fix soc v TOU (ne 100) pri ne-grid-charge
Some checks failed
CI and deploy / migration-check (push) Failing after 15s
CI and deploy / deploy (push) Has been skipped
2026-05-02 12:15:40 +02:00
Dusan Vojacek
fffe6c7185 fix rizeni pole pres reg340 jen home01
Some checks failed
CI and deploy / migration-check (push) Failing after 12s
CI and deploy / deploy (push) Has been skipped
2026-05-02 09:31:45 +02:00
Dusan Vojacek
bf3b10ca50 fix rezani pv a
Some checks failed
CI and deploy / migration-check (push) Failing after 10s
CI and deploy / deploy (push) Has been skipped
2026-05-01 13:12:21 +02:00
Dusan Vojacek
1e0300dd7e register 340 -omezovani vyrkonu pv pole (home-01)
Some checks failed
CI and deploy / migration-check (push) Failing after 11s
CI and deploy / deploy (push) Has been skipped
2026-05-01 12:51:28 +02:00
Dusan Vojacek
dede8d604d fix cutoff a grid peak shaving register
Some checks failed
CI and deploy / migration-check (push) Failing after 13s
CI and deploy / deploy (push) Has been skipped
2026-04-29 13:36:38 +02:00
Dusan Vojacek
342483b885 invert logic cutoff register
Some checks failed
CI and deploy / migration-check (push) Failing after 14s
CI and deploy / deploy (push) Has been skipped
2026-04-29 13:24:28 +02:00
Dusan Vojacek
89fb4f1924 fix idempotency gne port uctoff
Some checks failed
CI and deploy / migration-check (push) Failing after 19s
CI and deploy / deploy (push) Has been skipped
2026-04-29 13:09:43 +02:00
Dusan Vojacek
5593397fd3 fix cutoff
Some checks failed
CI and deploy / migration-check (push) Failing after 18s
CI and deploy / deploy (push) Has been skipped
2026-04-29 13:04:30 +02:00
Dusan Vojacek
afee62ba4e fix cutoff gen port
Some checks failed
CI and deploy / migration-check (push) Failing after 11s
CI and deploy / deploy (push) Has been skipped
2026-04-29 12:51:53 +02:00
Dusan Vojacek
50a0ca95f4 implementace LED loxone u zaporncyh cen
Some checks failed
CI and deploy / migration-check (push) Failing after 10s
CI and deploy / deploy (push) Has been skipped
2026-04-26 22:49:47 +02:00
Dusan Vojacek
1d04790f28 extend webhook per site
Some checks failed
CI and deploy / migration-check (push) Failing after 14s
CI and deploy / deploy (push) Has been skipped
2026-04-26 22:04:48 +02:00
Dusan Vojacek
5d7d7e2823 puldenni sltovoani , zruseni omemzeni na zakaz exportu pri zapornem sellu, hlubsi vybijeni ped zaporbnym nakupem
Some checks failed
CI and deploy / migration-check (push) Failing after 11s
CI and deploy / deploy (push) Has been skipped
2026-04-26 00:27:36 +02:00
Dusan Vojacek
6cf14ed25b idempotence zapisu 178 a 179 grid peak shaveing a grid cuttoff
Some checks failed
CI and deploy / migration-check (push) Failing after 10s
CI and deploy / deploy (push) Has been skipped
2026-04-20 11:41:57 +02:00
Dusan Vojacek
b8515f30df implmemtace cuttoff genportu
Some checks failed
CI and deploy / migration-check (push) Failing after 9s
CI and deploy / deploy (push) Has been skipped
2026-04-20 10:41:10 +02:00
Dusan Vojacek
43b594c8d5 solver nastavuje stavy deye
Some checks failed
CI and deploy / migration-check (push) Failing after 14s
CI and deploy / deploy (push) Has been skipped
2026-04-20 08:33:56 +02:00
Dusan Vojacek
7f3b0957cc fix discharge battery
Some checks failed
CI and deploy / migration-check (push) Failing after 18s
CI and deploy / deploy (push) Has been skipped
2026-04-19 23:46:16 +02:00
Dusan Vojacek
d8221e3169 prekopani SELL
Some checks failed
CI and deploy / migration-check (push) Failing after 15s
CI and deploy / deploy (push) Has been skipped
2026-04-19 22:48:51 +02:00
Dusan Vojacek
93f883f5e0 sql first refactor
Some checks failed
CI and deploy / migration-check (push) Successful in 5s
CI and deploy / deploy (push) Failing after 20s
2026-04-19 20:02:20 +02:00