EV telemetrie: skutečné čtení Teltonika TeltoCharge (konec stub-u)
Some checks failed
CI and deploy / migration-check (push) Failing after 23s
CI and deploy / deploy (push) Has been skipped

poll_ev_chargers četl placeholder ('available'/0 W) — EV spotřeba se nikdy
neodečítala z bazálu a session detekce nefungovala. Nyní: blok registrů 0-40
jedním FC 3 (oficiální protokol rev 0.5), parse_teltocharge_frame (status z
reg 6 → available/preparing/charging/..., výkon reg 38, energie session reg 39,
proud max L1-L3 reg 3-5). Při selhání čtení se vzorek NEzapisuje (fabrikovaný
available by falešně ukončoval session).

fn_telemetry_ev_charger_sample: + p_current_a (drop staré 7-arg signatury).
6 nových testů parseru; plná sada beze změny. Docs: modbus-registers-teltocharge.md.

Po deployi: home-01 ev-charger-1/2 začnou posílat reálná data; bazál se začne
čistit od EV (EMA 00:30); rebuild stats má smysl až po ~2 týdnech čisté historie.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dusan Vojacek
2026-06-11 22:10:46 +02:00
parent 53e9afb513
commit 5239463699
4 changed files with 186 additions and 10 deletions

View File

@@ -1,3 +1,11 @@
-- Vzorek telemetrie EV nabíječky (1min, Timescale). Od 2026-06-11 vč. proudu
-- (Teltonika reg 35, max fáze) — starou 7-arg signaturu dropnout (jinak by
-- volání s defaultem bylo ambiguózní).
drop function if exists ems.fn_telemetry_ev_charger_sample(
int, int, timestamptz, int, text, int, double precision
);
create or replace function ems.fn_telemetry_ev_charger_sample(
p_site_id int,
p_charger_id int,
@@ -5,7 +13,8 @@ create or replace function ems.fn_telemetry_ev_charger_sample(
p_connector_id int,
p_status text,
p_power_w int,
p_energy_kwh double precision
p_energy_kwh double precision,
p_current_a double precision default null
)
returns void
language sql
@@ -17,7 +26,8 @@ as $fn$
connector_id,
status,
power_w,
energy_kwh
energy_kwh,
current_a
)
values (
p_site_id,
@@ -26,10 +36,11 @@ as $fn$
p_connector_id,
p_status,
p_power_w,
p_energy_kwh
p_energy_kwh,
p_current_a
)
on conflict (charger_id, connector_id, measured_at) do nothing;
$fn$;
comment on function ems.fn_telemetry_ev_charger_sample is
'Insert telemetrie nabíječky EV (placeholder Modbus).';
'Vloží 1min vzorek telemetrie EV nabíječky (status, výkon, energie session, proud). Idempotentní na (charger, connector, čas).';