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>
47 lines
1.2 KiB
SQL
47 lines
1.2 KiB
SQL
-- Vzorek telemetrie EV nabíječky (1min, Timescale). Od 2026-06-11 vč. proudu
|
||
-- (Teltonika reg 3–5, 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,
|
||
p_measured_at timestamptz,
|
||
p_connector_id int,
|
||
p_status text,
|
||
p_power_w int,
|
||
p_energy_kwh double precision,
|
||
p_current_a double precision default null
|
||
)
|
||
returns void
|
||
language sql
|
||
as $fn$
|
||
insert into ems.telemetry_ev_charger (
|
||
site_id,
|
||
charger_id,
|
||
measured_at,
|
||
connector_id,
|
||
status,
|
||
power_w,
|
||
energy_kwh,
|
||
current_a
|
||
)
|
||
values (
|
||
p_site_id,
|
||
p_charger_id,
|
||
p_measured_at,
|
||
p_connector_id,
|
||
p_status,
|
||
p_power_w,
|
||
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
|
||
'Vloží 1min vzorek telemetrie EV nabíječky (status, výkon, energie session, proud). Idempotentní na (charger, connector, čas).';
|