Implement telemetry enhancements: add reading of Deye registers 145 and 179 in telemetry collector to derive is_export_limited and pv_derating_flags. Update fn_telemetry_inverter_sample to store these flags, and adjust related documentation and API endpoints accordingly.
Some checks failed
CI and deploy / migration-check (push) Failing after 19s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-04-22 23:02:14 +02:00
parent 1dfab8c7a1
commit c928e2234d
6 changed files with 74 additions and 15 deletions

View File

@@ -1,4 +1,6 @@
create or replace function ems.fn_telemetry_inverter_sample(
DROP FUNCTION IF EXISTS ems.fn_telemetry_inverter_sample;
CREATE OR REPLACE FUNCTION ems.fn_telemetry_inverter_sample(
p_site_id int,
p_inverter_id int,
p_measured_at timestamptz,
@@ -14,12 +16,14 @@ create or replace function ems.fn_telemetry_inverter_sample(
p_load_power_w int,
p_grid_import_total_wh bigint,
p_grid_export_total_wh bigint,
p_run_state int
p_run_state int,
p_is_export_limited boolean DEFAULT NULL,
p_pv_derating_flags int DEFAULT NULL
)
returns void
language sql
as $fn$
insert into ems.telemetry_inverter (
RETURNS void
LANGUAGE sql
AS $fn$
INSERT INTO ems.telemetry_inverter (
site_id,
inverter_id,
measured_at,
@@ -35,9 +39,11 @@ as $fn$
load_power_w,
grid_import_total_wh,
grid_export_total_wh,
run_state
run_state,
is_export_limited,
pv_derating_flags
)
values (
VALUES (
p_site_id,
p_inverter_id,
p_measured_at,
@@ -53,10 +59,12 @@ as $fn$
p_load_power_w,
p_grid_import_total_wh,
p_grid_export_total_wh,
p_run_state
p_run_state,
p_is_export_limited,
p_pv_derating_flags
)
on conflict (inverter_id, measured_at) do nothing;
ON CONFLICT (inverter_id, measured_at) DO NOTHING;
$fn$;
comment on function ems.fn_telemetry_inverter_sample is
'Insert jednoho vzorku telemetrie střídače (telemetry_collector).';
COMMENT ON FUNCTION ems.fn_telemetry_inverter_sample IS
'Insert jednoho vzorku telemetrie střídače (telemetry_collector). Volitelně is_export_limited / pv_derating_flags (Deye reg 145/179) pro vyloučení slotů z učení PV delty.';