Cannot store attribute value with correct type using IoTAgentUL

I need to store device attribute values ​​with correct type in OrionCB MongoDB.

Since I was unable to accomplish this, I dived into the code and found that IoTAgentUL (as well as IoTAgentJSON) is using OrionCB API v1

instead API v2

.

As I can see API v1

updateContext is sending data to MongoDB without , which means that each measure is saved as text.

On the other hand, I found that API v2

the update object is sending data to the MongoDB file with . It creates that I can store the values ​​of attributes with a type that benefits me when manipulating the data (i.e. creating indexes, sorting, etc.).

My question is if there is any solution to solve this problem using current implementations of IoT agents.

+3


source to share


1 answer


The only workaround I can imagine is when objects are automatically created by IoT agents to update the type of such objects themselves. I mean, AFAIK, you can update both the value and the type of an object.

In more detail I can think of a script that subscribes to all entities of a specific type (created by agents). Then when the object is created, it is notified by a script that automatically updates the entity's attribute type.



Note that you only need to modify the attribute types once, only when objects are created, not when the entity attribute is updated; thus your script needs something like an array or cache of already changed objects.

0


source







All Articles