Let’s assume I have Datapoints (I hope I’m using the right word) in one Asset like the following two:
[
{
"id": "example",
"version": 20,
"createdOn": 1700211591610,
"name": "Example Name",
"accessPublicRead": false,
"realm": "examplerealm",
"type": "ThingAsset",
"path": [
"example"
],
"attributes": {
"carData": {
"type": "JSONObject",
"value": {
"color": "green",
"shape": "sedan",
"speed": 100
},
"name": "carData",
"meta": {
"storeDataPoints": true
},
"timestamp": 1707483616321
}
}
}
]
[
{
"id": "example",
"version": 20,
"createdOn": 1700211591610,
"name": "Example Name",
"accessPublicRead": false,
"realm": "examplerealm",
"type": "ThingAsset",
"path": [
"example"
],
"attributes": {
"carData": {
"type": "JSONObject",
"value": {
"color": "red",
"shape": "truck",
"speed": 60
},
"name": "carData",
"meta": {
"storeDataPoints": true
},
"timestamp": 1707483616322
}
}
}
]
Is it possible to get all Datapoints (including historic) of "carData"
with "color": "green"
AND "shape": "sedan"
ordered by their "speed"
descending?
I tried the asset/query/
like this and it gives me the latest Datapoint with "color": "green"
:
{
"realm": {
"name": "examplerealm"
},
"types": [
"ThingAsset"
],
"names": [
{
"match": "EXACT",
"caseSensitive": true,
"value": "Example Name",
"negate": false,
"predicateType": "string"
}
],
"attributes": {
"items": [
{
"path": {
"paths": [
"color"
]
},
"name": {
"match": "EXACT",
"caseSensitive": true,
"value": "carData",
"negate": false,
"predicateType": "string"
},
"value": {
"predicateType": "string",
"value": "green"
}
}
]
}
}
If I throw an AND in there like in the following query, it just gives me the latest Datapoint ignoring the "color": "green"
and "shape": "sedan"
.
{
"realm": {
"name": "examplerealm"
},
"types": [
"ThingAsset"
],
"names": [
{
"match": "EXACT",
"caseSensitive": true,
"value": "Example Name",
"negate": false,
"predicateType": "string"
}
],
"attributes": {
"items": [
{
"operator": "AND",
"items": [
{
"path": {
"paths": [
"color"
]
},
"name": {
"match": "EXACT",
"caseSensitive": true,
"value": "carData",
"negate": false,
"predicateType": "string"
},
"value": {
"predicateType": "string",
"value": "green"
}
},
{
"path": {
"paths": [
"shape"
]
},
"name": {
"match": "EXACT",
"caseSensitive": true,
"value": "carData",
"negate": false,
"predicateType": "string"
},
"value": {
"predicateType": "string",
"value": "sedan"
}
}
]
}
]
}
}
Also the asset/query/
endpoint seems only get me one Asset with the latest Datapoint.
There’s the /asset/datapoint/{assetId}/attribute/{attributeName}
endpoint, but that one seems to support only time-based filtering.
If it’s not possible to do this with just the HTTP API, is there any other way with for example Rules? Or is the only solution to scrape all of the data and do the filtering and ordering outside of Openremote?