I seem to remember reading that it is possible to use the Attribute Links to do some basic data transformation e.g. multiple or divide the value etc. I can’t find where I read this but can anyone can advise if this is possible.
Thanks
I seem to remember reading that it is possible to use the Attribute Links to do some basic data transformation e.g. multiple or divide the value etc. I can’t find where I read this but can anyone can advise if this is possible.
Thanks
Hi!
In our documentation the attribute links are a bit hidden, correct.
We have some Agent Link documentation, which contains the filters used in Attribute Links.
However, in regards to data transformation, I have no experience at all
I’ve only used filters in the past, not the converter haha
Here is an example of the Attribute Links input, maybe it helps!
[
{
"ref": {
"id": "<your asset id>",
"name": "<your attribute name>"
},
"filters": [
{
"type": "jsonPath",
"path": "$..events[?(@.attributeState.ref.name == 'targetTemperature')].attributeState.value"
},
{
"type": "regex",
"pattern": ".*(\\d)$",
"matchGroup": 1
},
{
"type": "substring",
"beginIndex": 10,
"endIndex": 15
}
],
"converter": {
"value1": "@INCREMENT",
"value2": "@DECREMENT",
"value3": "@TOGGLE",
"value4": "@NEGATE",
"value5": "@IGNORE"
}
}
]
Maybe @Don or @Rich can double check this attempt
If it’s fine, I can open a PR to add it to the official documentation.
Hi Martin,
The reason for my question is that sometimes we receive a temperature value from a Modbus device in the payload, and the value might come through as 18000 when it should actually be 18. To correct this, we need to divide the value by 1000.
We can handle this using rules, but that can get a bit fiddly, so I was considering using an Attribute Link instead. Alternatively, we could adjust the value directly in the payload decoder in ChirpStack, which might be the simplest approach.
Cheers,
Clint
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.