Attribute conversion from 12bytes data

Hi, how can I convert my asset’s attribute from 12byte data to extract my device’s status? Any way I can decode it in OpenRemote?

What you can do with the generic agents/protocols is limited and you don’t mention what agent type you are using.

I’ll assume it is one of the IO agents (TCP. UDP, websocket…), they deal with strings and its’ possible to work with binary/hex data by setting the agent attributes:

  • messageConvertHex
  • messageConvertBinary

This will get you binary/hex data represented as strings; then you will have to use the standard generic AgentLink configuration for filtering and matching messages in attributes.

You can use the substring value filter to extract the byte sequence of interest out of your 12 bytes and then use a value converter in your agent link to map the different values to status strings, as a rough example:

005AF2C340EE → Value Filter (substring with beginIndex: 4, endIndex: 5) → F2 → valueConverter ({"F2": "OK", "F3": "Error"}

If you need to do more complex processing of the 12 bytes then you’ll need to extend the agent/protocol and write some java.

Hi rich,

I am using HTTP agent.
So basically, I need to convert the 12bytes payload into binary then extract bit sequence for get 10 different sensor value.

When you say extend the agent and write some java, do I need to modify the source code to do that?

I’ve just added the ability to use messageConvertBinary and/or messageConvertHex options on the HTTPAgentLink or on the whole HTTP Agent; there are tests covering its’ usage with sub string value filter and value converter:

Try a manager image with a newer timestamp than this post and hopefully it allows you to achieve what you want.

Hi Rich,

I’m using MQTT Agent.
I’m using the substring Value Filter to extract F2 and I want to convert it into decimal
and I would like to know how to find the agent attributes.

Hi @Rich ,

I’m using MQTT Agent.
I’m using the attribute Value converter but I don’t know which kind of parameter I can put in the key parameter.

The code contains some documentation that might help: openremote/AgentLink.java at ec3a104dedadb7b3f68fe2e8941f168b86e97ed6 · openremote/openremote · GitHub

So the key should match the incoming string value and you can then convert it to a new value (if I understand this correctly)

Thanks for your answer.
According to the documentation ( User Guide: Agent Overview · openremote/openremote Wiki · GitHub) , the incoming value will be converted to JSON and if this string matches a key in the converter then the value of that key will be pushed through to the attribute.
Here is what I did:


The json of the value converter is:

I am trying to convert the hexadecimal value to decimal. Is there a better way to do it?

If you have managed to filter the F2 value then the value converter should work if you just make a simple change because the value converter takes the whole filtered value as the key:

{
  "00": 0,
  "01": 1,
...
  "F2": 242
}

Just put the values of interest into the value converter.

We need to look at simplifying the whole value filtering/converting and ideally provide a more flexible programmatic solution than the current declarative solution.