fix rizeni pole pres reg340 jen home01
Some checks failed
CI and deploy / migration-check (push) Failing after 12s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-05-02 09:31:45 +02:00
parent ed88ef8910
commit fffe6c7185
9 changed files with 86 additions and 42 deletions

View File

@@ -1,4 +1,4 @@
-- Cap pro Deye reg 340 (max solar power, W): součet nominal_power_wp řiditelných PV polí na invertoru.
-- Cap pro reg 340 max solar power (W): součet nominal_power_wp řiditelných PV polí na invertoru.
create or replace function ems.fn_inverter_pv_a_max_w(p_inverter_id int)
returns int
language sql
@@ -11,4 +11,4 @@ as $$
$$;
comment on function ems.fn_inverter_pv_a_max_w(int) is
'Cap pro Deye reg 340 (max solar power, W) = součet nominal_power_wp řiditelných PV polí na daném invertoru. 0 = EMS reg 340 neaktivní (skip zápisu).';
'Cap pro reg 340 (max solar power, W) = součet nominal_power_wp řiditelných PV polí na daném invertoru. 0 = EMS reg 340 neaktivní (skip zápisu).';

View File

@@ -0,0 +1,25 @@
-- True pokud má lokalita aspoň jedno PV pole se zeleným bonusem v aktuálním kalendářním dni (Europe/Prague).
create or replace function ems.fn_site_has_active_green_bonus_pv(p_site_id int)
returns boolean
language sql
stable
as $$
select exists (
select 1
from ems.asset_pv_array apa
where apa.site_id = p_site_id
and apa.green_bonus_czk_kwh is not null
and apa.green_bonus_czk_kwh > 0
and (
apa.green_bonus_valid_from is null
or (timezone('Europe/Prague', now()))::date >= apa.green_bonus_valid_from
)
and (
apa.green_bonus_valid_to is null
or (timezone('Europe/Prague', now()))::date < apa.green_bonus_valid_to
)
);
$$;
comment on function ems.fn_site_has_active_green_bonus_pv(int) is
'EMS reg 340: true pokud existuje PV pole na site se zeleným bonusem (green_bonus_czk_kwh > 0) platné dnes v Europe/Prague.';