diff --git a/queries/hottis.sql b/queries/hottis.sql index 8d4ea42..c1816e2 100644 --- a/queries/hottis.sql +++ b/queries/hottis.sql @@ -146,3 +146,37 @@ create or replace view ntp_server_variables_v as from measurements where application = 'TSM' and device = '172.16.13.10'; + +-- Status string `unit:"" json:"status"` +-- Timestamp string `unit:"" json:"timestamp"` +-- VoltageL1 float32 `unit:"V" json:"voltageL1"` +-- VoltageL2 float32 `unit:"V" json:"voltageL2"` +-- VoltageL3 float32 `unit:"V" json:"voltageL3"` +-- CurrentL1 float32 `unit:"A" json:"currentL1"` +-- CurrentL2 float32 `unit:"A" json:"currentL2"` +-- CurrentL3 float32 `unit:"A" json:"currentL3"` +-- PowerL1 float32 `unit:"W" json:"powerL1"` +-- PowerL2 float32 `unit:"W" json:"powerL2"` +-- PowerL3 float32 `unit:"W" json:"powerL3"` +-- TotalImportEnergy float32 `unit:"Wh" json:"totalImportEnergy"` +-- TotalExportEnergy float32 `unit:"Wh" json:"totalExportEnergy"` +-- Cnt int `unit:"" json:"cnt"` + + +create or replace view car_values_v as + select time, + cast(values->'VoltageL1'->>'value' as float) as voltage_l1, + cast(values->'VoltageL2'->>'value' as float) as voltage_l2, + cast(values->'VoltageL3'->>'value' as float) as voltage_l3, + cast(values->'CurrentL1'->>'value' as float) as current_l1, + cast(values->'CurrentL2'->>'value' as float) as current_l2, + cast(values->'CurrentL3'->>'value' as float) as current_l3, + cast(values->'PowerL1'->>'value' as float) as power_l1, + cast(values->'PowerL2'->>'value' as float) as power_l2, + cast(values->'PowerL3'->>'value' as float) as power_l3, + cast(values->'TotalImportEnergy'->>'value' as float) as total_import_energy, + cast(values->'TotalExportEnergy'->>'value' as float) as total_export_energy, + values->'Status'->>'value' as status, + device + from measurements + where application = 'Car'; \ No newline at end of file