Data Model
ThingsBoard maps LwM2M object resources to its own Attributes and Time-Series Data via the device profile. No code is required on the device side — the mapping is fully configured in ThingsBoard.
See Getting Started for device profile setup and connection details.
Reading Resources as Attributes
Section titled “Reading Resources as Attributes”Check the Attribute box for an LwM2M resource in the device profile to store its value as a ThingsBoard attribute. ThingsBoard reads the value during device registration and on each Registration Update.
Example: Resource /3/0/2 (Device Serial Number) → ThingsBoard attribute serialNumber.
Optionally check Observe alongside Attribute to subscribe to real-time changes. The attribute value is then updated whenever the resource changes on the device.
Reading Resources as Telemetry
Section titled “Reading Resources as Telemetry”Check the Telemetry box for a resource to store its values as time-series data. Typically combined with Observe so ThingsBoard receives push notifications on value change.
Example: Resources /3/0/9 (Battery Level), /6/0/0 (Latitude), /6/0/1 (Longitude) → telemetry keys batteryLevel, lat, lon.
Writing to Devices via Shared Attributes
Section titled “Writing to Devices via Shared Attributes”To push configuration updates to a device, map an LwM2M resource as an Attribute and enable Observe. When the corresponding ThingsBoard shared attribute is changed (via the UI, REST API, dashboard widget, or Rule Engine), ThingsBoard automatically sends a Write operation to the device.
Example: Change the timezone shared attribute in ThingsBoard → ThingsBoard sends WriteUpdate to /3/0/15 (Timezone resource).
Observe Strategies
Section titled “Observe Strategies”The Observe strategy controls how ThingsBoard groups observation requests sent to the device. Configure it in the LwM2M Model section of the device profile’s Transport configuration tab.
| Strategy | Description | Trade-off |
|---|---|---|
| Single (default) | Each resource is observed individually | Best accuracy · Higher traffic |
| Composite All | All resources observed in one Composite Observe request | Lowest traffic · Less granular |
| Composite by Object | Resources grouped per object type | Balanced |
Changes to the observe strategy take effect immediately if the LwM2M session is active, or on the next Registration Update if not.
Notification Attributes (NOTIFICATION class)
Section titled “Notification Attributes (NOTIFICATION class)”Notification attributes fine-tune when the device sends observation notifications. Set them via the WriteAttributes RPC command or in the device profile.
| Attribute | Description |
|---|---|
pmin | Minimum period (seconds) — minimum time between two notifications |
pmax | Maximum period (seconds) — device must notify at least this often, even if the value has not changed. 0 means disabled. |
gt | Greater Than — notify when the resource value rises above this threshold |
lt | Less Than — notify when the resource value falls below this threshold |
st | Step — notify when the resource value changes by at least this amount |
Example — set pmin and pmax on resource /19/0/0:
{ "method": "WriteAttributes", "params": {"id": "/19/0/0", "attributes": {"pmin": 10, "pmax": 120}}}Keys vs. Resource IDs
Section titled “Keys vs. Resource IDs”RPC commands and attribute references can use either the full resource path or a user-defined key:
| Format | Example |
|---|---|
| Resource ID | /3/0/9 |
| Resource ID + version | /3_1.2/0/9 |
| Key (custom name) | batteryLevel |
To use a key, assign it to the resource in the device profile (Transport configuration → LwM2M Model → Attributes → key name).