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
)
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
  )
  values (
    p_site_id,
    p_charger_id,
    p_measured_at,
    p_connector_id,
    p_status,
    p_power_w,
    p_energy_kwh
  )
  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).';
