LwM2M: objects information and reading data through API

Hello, I am trying to write python script and would like some help here:

  1. Is it possible to read all added LwM2M objects (device protocols) through API?
  2. I found a way to read lwm2m object’s historic data through events, if I mark object resource as event in device protocol window. But it is not very convenient, because multiple instance resources are shown as separate events.
  3. So, is there a different way to read all lwm2m object’s historic data which was sent by device with ID ******?
  4. How much time historical data is saved in cumulocity server?

i have a py script and i successfully read measurement/measurements and event/events, but it’s not what i want.

Hi Erikas,

I’ve added my answers inline.

The API for this is not documented and can be subject to change. We don’t recommend any automated applications to use undocumented API endpoints.

As you have already mentioned, currently it is only possible to see the historic data of an LWM2M object in the platform if you enable measurement/event functionality for the desired LWM2M object’s resources.
There is also the custom action functionality option to forward LWM2M object resource value to a custom decoder microservice which can be used to apply a custom logic. (Link: LWM2M - Cumulocity documentation)

May I learn which environment do you use? In our cloud environments, we are developing a new feature which would be relevant to have LWM2M object(s) resources in single message.

If you don’t have a retention rule policy then all the historical data is kept.

Best regards,
Özge

1 Like

Understood, i will use events then.

I am creating my own software to get archive data through API, because it is not visible in cumulocity webUI now. It is not much, just for testing. My suggestion for you:

  1. create direct endpoint to reach LwM2M object’s archive data;
  2. Add archive data for each object in webUI.

Also, i am trying to reduce data that’s sent from cumulocity, but fragmentType parameter does not work.

My type is: "type": "c8y_latestEventLog_0_2",. What value i need to specify for fragmentType and fragmentValue ?

hello, is there any information about this?

Hi Erikas,

Sorry for the delayed reply.

Thanks for your feedback on that. We want to tackle this in a different way.
There will be a new feature available soon in our Cloud environments (cumulocity.com, …) that publishes the received LWM2M device raw message in SENML_JSON format to Cumulocity’s MQTT Service.
The published message will contain the LWM2M object(s) resources together as they are received and not individually for each LWM2M object’s resources.
A listener/consumer microservice needs to be implemented to subscribe the MQTT topic and apply additional conversion or business logic.
If you would like to archieve the data, you can also make the listener/consumer microservice to forward this to Cumulocity’s DataHub.

LWM2M agent adds the object and resource indexes to the event type defined in LWM2M device protocol configuration automatically as fragmentType_<objectInstanceId>_<resourceId>.

When the new feature that is described above is available, you can apply any custom logic in your consumer/listener microservice. The raw device data will be published to Cumulocity’s MQTT Service without applying the configurations defined in LWM2M device protocol.

I understand that, but when i try to specify API parameters (fragmentType and fragmentValue) - they don’t work.

This does not look like a solution for me, because I won’t be listening for messages all the time. What I want - connect one time in a week, to read what data meter has sent.

For now, i achieved everything i wanted with events logic, but this required too much effort to achieve :smiley:

Actually you would need to filter with type query parameter:

Example request:
GET /event/events?type=<event_type_specified_for_LWM2M_object_resource>_<objectInstanceId>_<resourceId>.

It is not fragmentType and fragmentValue query parameters.

Cumulocity - OpenAPI (https://cumulocity.com/api/core/#operation/getEventCollectionResource)