Files
ems/db/routines/R__048_fn_telemetry_heat_pump_sample.sql
Dusan Vojacek d63a85a2ea
Some checks failed
CI and deploy / migration-check (push) Failing after 7m29s
CI and deploy / deploy (push) Has been skipped
TČ Samsung přes MIM-B19N: endpoint 172.16.1.17, plný poll, registry doc
- V096: endpoint home-01 TČ z placeholderu 192.168.1.103 na reálný Waveshare
  RS485 TO POE ETH (B) 172.16.1.17:502; telemetry_heat_pump.room_temp_c.
- R__048: fn_telemetry_heat_pump_sample rozšířena (water_inlet, room_temp,
  defrost, alarm_code) — drop/comment bez parametrů dle konvence.
- poll_heat_pump: místo TODO stubu (zapisoval dummy 45/55 °C!) skutečné čtení
  MIM bloku 50-75 + defrost reg 2; gate na comm_status ready (jinak skip);
  operating_mode off/heat/cool/auto/dhw/error; power_w NULL (MIM příkon nemá).
- docs/04-modules/modbus-registers-mim-b19n.md (mapa, 9600 8E1, DIP adresa,
  troubleshooting E6xx) + heat-pump.md odkaz.

Živý stav: TCP :502 OK, Modbus bez odpovědi (čeká na protokol převodníku /
paritu EVEN / polaritu A-B — checklist v docu).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 18:24:10 +02:00

56 lines
1.5 KiB
SQL

-- Insert 1min vzorku telemetrie TČ (MIM-B19N). Bez overloadů — při změně
-- signatury drop bez parametrů (konvence CLAUDE.md).
drop function if exists ems.fn_telemetry_heat_pump_sample;
create or replace function ems.fn_telemetry_heat_pump_sample(
p_site_id int,
p_heat_pump_id int,
p_measured_at timestamptz,
p_power_w int,
p_outdoor_temp_c double precision,
p_water_outlet_temp_c double precision,
p_tuv_tank_temp_c double precision,
p_operating_mode text,
p_water_inlet_temp_c double precision default null,
p_room_temp_c double precision default null,
p_defrost_active boolean default null,
p_alarm_code int default null
)
returns void
language sql
as $fn$
insert into ems.telemetry_heat_pump (
site_id,
heat_pump_id,
measured_at,
power_w,
outdoor_temp_c,
water_outlet_temp_c,
tuv_tank_temp_c,
operating_mode,
water_inlet_temp_c,
room_temp_c,
defrost_active,
alarm_code
)
values (
p_site_id,
p_heat_pump_id,
p_measured_at,
p_power_w,
p_outdoor_temp_c,
p_water_outlet_temp_c,
p_tuv_tank_temp_c,
p_operating_mode,
p_water_inlet_temp_c,
p_room_temp_c,
p_defrost_active,
p_alarm_code
)
on conflict (heat_pump_id, measured_at) do nothing;
$fn$;
comment on function ems.fn_telemetry_heat_pump_sample is
'Insert telemetrie TČ z MIM-B19N pollu (voda in/out, TUV, prostorová teplota, defrost, alarm). power_w je NULL — MIM příkon neměří (nutný elektroměr).';