Add generic ENLYZE power meter pipeline
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
-- Set :meter, :from and :to from Grafana variables.
|
||||
-- Current power:
|
||||
SELECT timestamp AS "time", active_power_total_kw AS "value"
|
||||
FROM power_meter_readings WHERE meter = '${meter}' AND $__timeFilter(timestamp);
|
||||
|
||||
-- Energy today / rolling 24h (counter increments are reset-safe).
|
||||
SELECT COALESCE(sum(energy_delta_kwh), 0) AS kwh
|
||||
FROM power_meter_readings
|
||||
WHERE meter = '${meter}' AND timestamp >= now() - interval '24 hours';
|
||||
|
||||
-- Frequency and outages in selected period.
|
||||
SELECT min(grid_frequency_hz) AS frequency_min_hz, max(grid_frequency_hz) AS frequency_max_hz,
|
||||
COALESCE(sum(outage_delta), 0) AS outages
|
||||
FROM power_meter_readings WHERE meter = '${meter}' AND $__timeFilter(timestamp);
|
||||
@@ -46,3 +46,27 @@ CREATE TABLE IF NOT EXISTS material_application_snapshots (
|
||||
|
||||
CREATE INDEX IF NOT EXISTS material_application_snapshots_machine_time_idx
|
||||
ON material_application_snapshots (calculation_id, machine_id, timestamp);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS power_meter_readings (
|
||||
meter text NOT NULL,
|
||||
timestamp timestamptz NOT NULL,
|
||||
energy_total_kwh double precision NOT NULL,
|
||||
energy_delta_kwh double precision NOT NULL,
|
||||
active_power_total_kw double precision NOT NULL,
|
||||
grid_frequency_hz double precision NOT NULL,
|
||||
power_outages double precision NULL,
|
||||
outage_delta double precision NULL,
|
||||
phase_active_power_kw jsonb NOT NULL DEFAULT '{}'::jsonb,
|
||||
PRIMARY KEY (meter, timestamp)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS power_meter_readings_time_idx
|
||||
ON power_meter_readings (meter, timestamp DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS power_meter_monthly_reports (
|
||||
meter text NOT NULL,
|
||||
month text NOT NULL,
|
||||
report_path text NOT NULL,
|
||||
summary jsonb NOT NULL,
|
||||
generated_at timestamptz NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (meter, month)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user