create or replace view badesee_temperature_v as
  select time, 
         cast(values->'Temp_Red'->>'value' as float) as Temp1,
         cast(values->'Temp_White'->>'value' as float) as Temp2,
         cast(values->'Temp_Black'->>'value' as float) as Temp3,
         cast(values->'Battery'->>'value' as float) as battery,
         attributes->>'Status' as status,
         device
    from measurements
    where application = 'de-hottis-saerbeck-monitoring' and
          device = 'eui-a84041318187ec13';

create or replace view cubecell_threeway_temperature_v as
  select time,
         cast(values->'Temperature1'->>'value' as float) as Temp1,
         cast(values->'Temperature2'->>'value' as float) as Temp2,
         cast(values->'Temperature3'->>'value' as float) as Temp3,
         device
    from measurements
    where application = 'de-hottis-saerbeck-monitoring' and
    device = 'eui-70b3d57ed0068fa4';


