File size: 464 Bytes
1129495
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
SELECT
  a.name AS asset_name,
  ad.timestamp + INTERVAL '3 hours' AS local_time,
  jsonb_object_agg(ad.attribute_name, ad.value) AS sensor_data
FROM openremote.asset a
JOIN openremote.asset_datapoint ad ON a.id = ad.entity_id
WHERE a.id = (
  SELECT id FROM openremote.asset
  WHERE REPLACE(LOWER(name), ' ', '') = REPLACE(LOWER('ColdRoom1'), ' ', '')
  ORDER BY version DESC LIMIT 1
)
GROUP BY a.name, ad.timestamp
ORDER BY ad.timestamp DESC
LIMIT 1