Files
ems/db/routines/R__092_fn_telemetry_pool_pump_sample.sql
Dusan Vojacek ccdca068a1 DB: bazénové čerpadlo přes Shelly relé (V085)
- ems.asset_pool_pump (endpoint http, rated_power_w, min_run_min,
  daily_runtime_min jako aktuální sezónní hodnota, schedulable)
- ems.telemetry_pool_pump — 1min hypertable (is_on, power_w, energy_wh_total)
- signal_def POOL_PUMP_ON (bool) pro ovládání přes signal infrastrukturu
- fn_telemetry_pool_pump_sample (R__092), vw_asset_pool_pump_http_poll (R__093)
- fn_signal_enqueue_bool (R__094) — SQL-first zařazení bool signálu do fronty

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 22:37:42 +02:00

33 lines
734 B
SQL

create or replace function ems.fn_telemetry_pool_pump_sample(
p_site_id int,
p_pump_id int,
p_measured_at timestamptz,
p_is_on boolean,
p_power_w int,
p_energy_wh_total bigint
)
returns void
language sql
as $fn$
insert into ems.telemetry_pool_pump (
site_id,
pump_id,
measured_at,
is_on,
power_w,
energy_wh_total
)
values (
p_site_id,
p_pump_id,
p_measured_at,
p_is_on,
p_power_w,
p_energy_wh_total
)
on conflict (pump_id, measured_at) do nothing;
$fn$;
comment on function ems.fn_telemetry_pool_pump_sample is
'Insert 1min telemetrie bazénového čerpadla (Shelly Switch.GetStatus: output, apower, aenergy.total). Volá telemetry_collector.poll_pool_pumps.';