create or replace view pv_power_v as select time, cast(values->'PowerActive'->>'value' as float) as power, values->'Status'->>'status' as status, device from measurements where application = 'PV'; create or replace view pv_total_import_v as select time, cast(values->'Power'->>'value' as float) as power, device from measurements where application = 'Power' and device = 'Total' and attributes->>'Status' = 'Ok'; create or replace view power_v as select time, cast(values->'Power'->>'value' as float) as power, device from measurements where application = 'Power' and attributes->>'Status' = 'Ok'; create or replace view temperature_heating_v as select time, cast(values->'Value'->>'value' as float) as temperature, device from measurements where application = 'Temperature Heating'; create or replace view gas_v as select time, cast(values->'Volume'->>'value' as float) as volume, device from measurements where application = 'Gas' and attributes->>'Status' = 'Ok'; create or replace view temperature_v as select time, cast(values->'Value'->>'value' as float) as temperature, device from measurements where application in ('Temperature Multisensor', 'Temperature Shelly Plus HT') union select time, cast(values->'Temperature'->>'value' as float) as temperature, device from measurements where application = 'Zigbee2MQTT Hottis Eupenstr.' and attributes->>'DeviceModel' in ('WSDCGQ11LM', 'WSDCGQ01LM'); create or replace view voltage_v as select time, cast(values->'Voltage'->>'value' as float) / 1000 as voltage, device from measurements where application = 'Zigbee2MQTT Hottis Eupenstr.' and attributes->>'DeviceModel' in ('WSDCGQ11LM', 'WSDCGQ01LM'); create or replace view temperature2_v as select time, cast(values->'Value'->>'value' as float) as temperature, device from measurements where application = 'Temperature Wago'; create or replace view humidity_v as select time, cast(values->'Value'->>'value' as float) as humidity, device from measurements where application in ('Humidity Multisensor') union select time, cast(values->'Humidity'->>'value' as float) as temperature, device from measurements where application = 'Zigbee2MQTT Hottis Eupenstr.' and attributes->>'DeviceModel' in ('WSDCGQ11LM', 'WSDCGQ01LM'); create or replace view soil_v as select time, cast(values->'Water'->>'value' as float) as water, cast(values->'Conductance'->>'value' as float) as conductance, cast(values->'Temperature'->>'value' as float) as temperature, device from measurements where application = 'de-hottis-app01' and attributes->>'DeviceType' = 'dragino-lse01'; create or replace view co2_v as select time, cast(m.values->'CO2concentration'->>'value' as float) as co2concentration, cast(m.values->'Humidity'->>'value' as float) as humidity, cast(m.values->'Temperature'->>'value' as float) as temperature, cast(m.values->'Brightness'->>'value' as int) as brightness, m.device as device, d.attributes->>'Label' as label from measurements m, devices d where m.application = 'de-hottis-app01' and m.attributes->>'DeviceType' = 'hottis-scd30' and m.device = d.label; create or replace view locative_v as select time, device as person, values->'Location'->>'value' as location, values->'Trigger'->>'value' as direction from measurements where application = 'Locative'; create or replace view router_v as select time, device, cast(values->'wan-in'->>'value' as int) as wanInOctetsPerSeconds, cast(values->'wan-out'->>'value' as int) as wanOutOctetsPerSeconds from measurements where application = 'SNMP' and device = '172.16.3.1'; create or replace view lora_sht21_v as select time, cast(values->'Humidity'->>'value' as float) as humidity, cast(values->'Temperature'->>'value' as float) as temperature, m.device as device, d.attributes->>'Label' as label from measurements m, devices d where m.application = 'de-hottis-app01' and m.attributes->>'DeviceType' = 'hottis-gy21' and m.device = d.label; create or replace view ntp_server_snmp_v as select time, device, cast(values->'load1'->>'value' as float) as laLoad1, cast(values->'lan-in'->>'value' as int) as lanInOctetsPerSeconds, cast(values->'lan-out'->>'value' as int) as lanOutOctetsPerSeconds from measurements where application = 'SNMP' and device = '172.16.13.10'; create or replace view ntp_server_variables_v as select time, device, cast(values->'rootdisp'->>'value' as float) as rootdisp 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';