zaheer140's picture
Upload 447 files
1129495 verified
Raw History Blame Contribute Delete
464 Bytes
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