Skip to content

Commit

Permalink
fix: change daily inverter energy calculation (et/somenergia-jardiner…
Browse files Browse the repository at this point in the history
…!103)

* delete some depreciated models and comments, added a time filter

* fix or and statement

* add a int model to choose the two inverter energies, and done a dm with monthy inverter energy
  • Loading branch information
Lugadur committed Feb 12, 2024
1 parent 922774c commit d7d2710
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 113 deletions.
4 changes: 1 addition & 3 deletions dbt_jardiner/models/jardiner/marts/_marts__exposures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ exposures:
En un futur també mostrarà l'estat d'alarmes.
depends_on:
- ref('dm_dset_energy_inverter__daily__accumulated')
- ref('dm_dset_energy_inverter__daily__reset_daily')
- ref('dm_dashboard_overview_monthly')
- ref('dm_dashboard_overview_instant')
- ref('dm_dashboard_overview__produccio_cartera')
Expand All @@ -41,7 +39,7 @@ exposures:
- ref('dm_plant_production_hourly')
- ref('dm_metrics_production_5min')
- ref('dm_plants')
- ref('dm_dset_energy_inverter__agg_monthly_for_om')
- ref('dm_dset_energy_inverter__monthly__reset_daily')

owner:
name: Gestió D'Actius
Expand Down
16 changes: 0 additions & 16 deletions dbt_jardiner/models/jardiner/marts/dm_dset_energy_inverter__5m.sql

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{ config(materialized="view") }}

with
inverter_energy_monthly as (
select
date_trunc('month', day, 'Europe/Madrid') as month_date,
plant_name,
device_name,
coalesce(sum(inverter_total_energy_kwh), sum(inverter_export_energy_kwh))/1000 as inverter_energy_mwh
from {{ ref("int_dset_energy_inverter__daily__reset_daily") }}
group by
date_trunc('month', day, 'Europe/Madrid'),
plant_name,
device_name
)
select
month_date as mes,
plant_name as nom_planta,
device_name as aparell,
inverter_energy_mwh as energia_inversor_mwh
from inverter_energy_monthly
where month_date > '2023-12-01'
order by month_date desc, plant_name, device_name

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ with
metric_name = 'energia_activa_exportada'
{# filter to discard previous day data which gets reset early morning #}
and extract(hour from ts at time zone 'Europe/Madrid') > 3
or metric_name = 'energia_activa_exportada_total'
group by
date_trunc('day', ts, 'Europe/Madrid'),
plant_uuid,
Expand All @@ -27,9 +28,34 @@ with
metric_name
),
inverter_energy_daily as (
select *, diff_inverter_energy_kwh as inverter_energy_kwh
select
day,
plant_name,
device_name,
case
when metric_name = 'energia_activa_exportada'
then diff_inverter_energy_kwh
else null
end as inverter_export_energy_kwh,
case
when metric_name = 'energia_activa_exportada_total'
then diff_inverter_energy_kwh
else null
end as inverter_total_energy_kwh
from inverter_energy_daily_metrics
order by day desc, plant_name, device_name
),
all_inverter_energy_metrics_in_one_tb as (
select
day,
plant_name,
device_name,
max(inverter_export_energy_kwh) as inverter_export_energy_kwh,
max(inverter_total_energy_kwh) as inverter_total_energy_kwh
from inverter_energy_daily
group by day, plant_name, device_name
)
select *
from inverter_energy_daily
from all_inverter_energy_metrics_in_one_tb
where day > '2023-12-15' --data aprox en que dset transforma correctament aquestes mètriques
order by day desc, plant_name, device_name

0 comments on commit d7d2710

Please sign in to comment.