Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ All parameters listed here correspond to settings in `tb-edge.yml` (or `tb-edge.

| Parameter | Env variable | Default | Description |
|-----------|-------------|---------|-------------|
| `state.defaultInactivityTimeoutInSec` | `DEFAULT_INACTIVITY_TIMEOUT` | `600` | Device inactivity timeout is a global configuration parameter that defines when the device will be marked as "inactive" by the server. The parameter value is in seconds. A user can overwrite this parameter for an individual device by setting the “inactivityTimeout server-side attribute (NOTE: expects value in milliseconds). We recommend this parameter to be in sync with session inactivity timeout ("transport.sessions.inactivity_timeout" or TB_TRANSPORT_SESSIONS_INACTIVITY_TIMEOUT) parameter which is responsible for detection of the stale device connection sessions. The value of the session inactivity timeout parameter should be greater or equal to the device inactivity timeout. Note that the session inactivity timeout is set in milliseconds while device inactivity timeout is in seconds. |
| `state.defaultInactivityTimeoutInSec` | `DEFAULT_INACTIVITY_TIMEOUT` | `600` | Global fallback for device inactivity detection, in seconds. ThingsBoard resolves a device's inactivity timeout in this order: per-device `inactivityTimeout` server-side attribute (milliseconds), then the device profile's **Device inactivity timeout** field, then this global value. Keep this parameter in sync with the session inactivity timeout (`transport.sessions.inactivity_timeout` or `TB_TRANSPORT_SESSIONS_INACTIVITY_TIMEOUT`), which controls stale transport sessions. The session inactivity timeout should be greater than or equal to the device inactivity timeout. The session inactivity timeout is in milliseconds; the device inactivity timeout is in seconds. |
| `state.defaultStateCheckIntervalInSec` | `DEFAULT_STATE_CHECK_INTERVAL` | `60` | Interval for checking the device state after a specified period. Time in seconds |
| `state.persistToTelemetry` | `PERSIST_STATE_TO_TELEMETRY` | `false` | Controls whether we store the device 'active' flag in attributes (default) or telemetry. If you decide to change this parameter, you should re-create the device info view as one of the following: If 'persistToTelemetry' is changed from 'false' to 'true': 'CREATE OR REPLACE VIEW device_info_view AS SELECT * FROM device_info_active_ts_view;' If 'persistToTelemetry' is changed from 'true' to 'false': 'CREATE OR REPLACE VIEW device_info_view AS SELECT * FROM device_info_active_attribute_view;' |
| `state.telemetryTtl` | `STATE_TELEMETRY_TTL` | `0` | Millisecond value defining time-to-live for device state telemetry data (e.g. 'active', 'lastActivityTime'). Used only when state.persistToTelemetry is set to 'true' and Cassandra is used for timeseries data. 0 means time-to-live mechanism is disabled. |
Expand Down
14 changes: 11 additions & 3 deletions src/content/_includes/docs/recipes/device-inactivity-alarm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,21 @@ The Rule Engine processes <DocLink product={props.product} path="user-guide/conn

### Step 1. Set inactivity timeout (optional)

The global default timeout is 600 seconds (`state.defaultInactivityTimeoutInSec` in `thingsboard.yml`).
The global default timeout is 600 seconds (`DEFAULT_INACTIVITY_TIMEOUT`). To shorten the timeout for the devices in this recipe, set it at the device profile level, the device level, or both.

To override it particular device, add an `inactivityTimeout` server attribute (value in milliseconds):
**Option A: Device profile (recommended)**

Open the **thermostat** profile and set **Device inactivity timeout** (under the **Details** tab) to `60 seconds`. The new value applies to every device assigned to the profile.

**Option B: Per-device override**

Add an `inactivityTimeout` server-side attribute on **Thermometer A1** to override the profile value for this device only:

- **Key**: `inactivityTimeout`
- **Type**: `Integer`
- **Value**: `60000` (60 seconds)
- **Value**: `60000` (60 seconds, milliseconds)

The per-device attribute always wins over the profile value. See <DocLink product={props.product} path='user-guide/connectivity-status'>device connectivity status</DocLink> for the full resolution order.

{props.product === Products.CE && (
<MultiProductImageGallery product={props.product} images={[
Expand Down
11 changes: 8 additions & 3 deletions src/content/_includes/docs/user-guide/connectivity-status.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ When a device connects, disconnects, or becomes inactive, ThingsBoard updates th
By default these are stored as **server-side attributes**. Set `PERSIST_STATE_TO_TELEMETRY=true` to store them as **time-series data** instead — useful when you need historical state graphs in dashboards. When stored as time-series, `STATE_TELEMETRY_TTL` controls the retention period (0 = unlimited).

<Aside type="note">
The `inactivityTimeout` server-side attribute on an individual device (in milliseconds) overrides `DEFAULT_INACTIVITY_TIMEOUT` for that device only.
ThingsBoard resolves a device's inactivity timeout in this order:
1. The `inactivityTimeout` server-side attribute on the device (milliseconds), if set.
2. The **Device inactivity timeout** field on the device's profile, if set.
3. The global `DEFAULT_INACTIVITY_TIMEOUT` fallback (seconds).

See <DocLink product={props.product} path='user-guide/device-profiles/#device-inactivity-timeout'>device profile inactivity settings</DocLink> for the profile-level field.
</Aside>

## Connectivity Events
Expand All @@ -40,7 +45,7 @@ The Device State service fires four event types into the Rule Engine, each mappe

## Inactivity Detection

A device is marked **inactive** when no activity is received for `DEFAULT_INACTIVITY_TIMEOUT` seconds (default: 600 s / 10 minutes). ThingsBoard checks all devices on a schedule controlled by `DEFAULT_STATE_CHECK_INTERVAL` (default: 60 s).
A device is marked **inactive** when no activity is received within its effective inactivity timeout. ThingsBoard resolves the value per device in this order: per-device `inactivityTimeout` server attribute (milliseconds), then the device profile's **Device inactivity timeout** field, then the global `DEFAULT_INACTIVITY_TIMEOUT` (seconds, default 600 s / 10 minutes). ThingsBoard checks all devices on a schedule controlled by `DEFAULT_STATE_CHECK_INTERVAL` (default: 60 s).

**Transport session vs device inactivity** — these are separate timeouts:
- `DEFAULT_INACTIVITY_TIMEOUT` — when the Device State service marks a device inactive
Expand Down Expand Up @@ -125,7 +130,7 @@ Time is divided into consecutive **reporting periods** of fixed length (controll
</tr>
<tr>
<td><code>TB_TRANSPORT_SESSIONS_INACTIVITY_TIMEOUT</code></td>
<td><code>300000</code></td>
<td><code>600000</code></td>
<td>Milliseconds before an idle transport session is closed</td>
</tr>
</tbody>
Expand Down
15 changes: 14 additions & 1 deletion src/content/_includes/docs/user-guide/device-profiles.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Clicking a profile opens a details panel with the following tabs:

| Tab | Contents |
|-----|---------|
| **Details** | Profile name, default dashboard, rule chain, firmware and software version |
| **Details** | Profile name, default dashboard, rule chain, firmware and software version, <DocLink product={props.product} path='user-guide/device-profiles/#device-inactivity-timeout'>device inactivity timeout</DocLink> |
| <DocLink product={props.product} path='user-guide/device-profiles/#transport-configuration'>Transport Configuration</DocLink> | Protocol-specific settings: authentication, payload format, topic filters |
| <DocLink product={props.product} path='user-guide/calculated-fields' target="_blank">Calculated Fields</DocLink> | Formulas for computing derived metrics from device telemetry or attributes |
| <DocLink product={props.product} path='user-guide/alarm-rules' target="_blank">Alarm Rules</DocLink> | Conditions, severity levels, and actions applied to all devices in this profile |
Expand Down Expand Up @@ -67,3 +67,16 @@ Define conditions that apply to all devices in this profile — for example, tri
### Provisioning

Control how new devices are created and authenticated when they first connect. See <DocLink product={props.product} path='user-guide/provisioning' target="_blank">Provisioning</DocLink>.

### Device inactivity timeout

Set how long a device may be silent before ThingsBoard marks it inactive. Choose the unit from the dropdown (seconds, minutes, hours, or days). Leave the field empty or set it to 0 to fall back to the global `DEFAULT_INACTIVITY_TIMEOUT` setting.

The profile-level value applies to every device in the profile, unless a device has its own `inactivityTimeout` server attribute, which always takes priority.

Resolution order at runtime:
1. Per-device `inactivityTimeout` server attribute (milliseconds), if set.
2. **Device inactivity timeout** field on this profile, if set.
3. Global `DEFAULT_INACTIVITY_TIMEOUT` fallback (seconds, default 600).

Updating the profile value propagates to all assigned devices without a restart. See <DocLink product={props.product} path='user-guide/connectivity-status'>device connectivity status</DocLink> for how inactivity is detected and reported.