I am trying to combine elements from payload properties, but the more i look at it, the more confused I get
The concept:
There are rooms, rooms have devices, devices have properties.
Changes on the properties as stored in the hasProp
property
I have this object:
{
"payload": {
"rooms": [
{
"devices": [
"device:netatmo_outdoor"
],
"id": "room:balcony",
"name": "balcony"
}
],
"device": [
{
"id": "device:netatmo_outdoor",
"measures": [
"prop:temperature",
"prop:humidity",
"prop:battery",
"prop:pressure"
],
"name": "netatmo_outdoor"
}
],
"prop": [
{
"id": "prop:battery",
"name": "battery",
"unit": "%"
},
{
"id": "prop:co2",
"name": "CO2",
"unit": "CO2"
},
{
"id": "prop:humidity",
"name": "humidity",
"unit": "%"
},
{
"id": "prop:linkquality",
"name": "link quality",
"unit": "LQI"
},
{
"id": "prop:motion",
"name": "motion"
},
{
"id": "prop:noise",
"name": "noise",
"unit": "dB"
},
{
"id": "prop:on",
"name": "on",
"unit": "-"
},
{
"id": "prop:pressure",
"name": "pressure",
"unit": "hP"
},
{
"id": "prop:temperature",
"name": "temperature",
"unit": "C"
}
],
"hasProp": [
{
"in": "device:netatmo_outdoor",
"out": "prop:temperature",
"timestamp": "2022-10-06T08:38:45.576273770Z",
"value": 21.85
}
]
}
}
and I would something like this as output:
[
{
"room": "livingroom",
"devices": [
{
"device": "netato_outdoor",
"properties": [
{
"property": "temperature",
"unit": "C",
"values": [
{
"value": 21.1,
"timestamp": "2022-10-06T06:09:08.415Z"
}
]
},
{ ... }
]
},
{ ... }
]
},
{ ... }
]
I had an expression like:
{"payload": *.rooms{
$.name: {"devices":[
**.devices.{
"device": $,
"measurements":{"value":$$.payload.hasProp[in=$].value, "timestamp": $$.payload.hasProp[in=$].timestamp}
}
]}
}}
The positional hasProp[in=$]
in measurements does not want to work, I guess because of the context that has changed, but how do I get the values out of it ?