Skip to content

Commit c5ea444

Browse files
committed
doc: Entity management API documentation
1 parent ac991c0 commit c5ea444

File tree

7 files changed

+767
-481
lines changed

7 files changed

+767
-481
lines changed

docs/src/operate/registration/deregister.md renamed to docs/src/legacy/deregister.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Deregister entities
33
tags: [Child-Device, Registration]
44
sidebar_position: 2
5-
description: Deregister child devices and services from %%te%%
5+
description: Deregister child devices and services from %%te%% using mosquitto_sub
66
---
77

88
# Deregister entities
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Auto-registration
3+
tags: [Child-Device, Registration]
4+
sidebar_position: 1
5+
description: Auto-register child devices and services over MQTT
6+
---
7+
8+
# Auto Registration
9+
10+
%%te%% provides an auto-registration mechanism for clients that do not want to do an explicit registration.
11+
To leverage this, they must conform to the **default topic scheme** that clearly demarcates the `device` and `service` as follows:
12+
13+
```
14+
te/device/<device_id>/service/<service_id>
15+
```
16+
17+
With auto-registration, when a measurement message is published to `te/device/rpi1001///m/cpu_usage` topic
18+
without a prior explicit registration of that entity,
19+
a `child-device` entity: `device/rpi1001//` is auto-registered as an **immediate child device** of the main device
20+
before the `cpu_usage` measurement is associated to it.
21+
22+
Similarly, publishing to `te/device/rpi1002/service/collectd/m/cpu_usage` would result in the auto-registration of
23+
both the `child-device` entity: `device/rpi1002//` and its `service` entity: `device/rpi1002/service/collectd`.
24+
25+
The auto-registered entities are persisted with the local MQTT broker by the `tedge-agent` with their auto-generated registration messages.
26+
For example, the child device `device/rpi1002//` is registered as follows:
27+
28+
```sh te2mqtt formats=v1
29+
tedge mqtt pub -r 'te/device/rpi1002//' '{
30+
"@type": "child-device",
31+
"@parent":"device/main//",
32+
"name": "rpi1002",
33+
}'
34+
```
35+
36+
Similarly, the service: `device/rpi1002/service/collectd` is registered as follows:
37+
38+
```sh te2mqtt formats=v1
39+
tedge mqtt pub -r 'te/device/rpi1002/service/collectd' '{
40+
"@type": "service",
41+
"@parent":"device/rpi1002//",
42+
"name": "collectd",
43+
}'
44+
```
45+
46+
:::note
47+
The %%te%% main device is pre-registered with the reserved default topic identifier: `device/main//`.
48+
:::
49+
50+
## Configuration
51+
52+
The auto-registration feature is turned on by default, ideal for simple fleets with only a single level of child devices,
53+
as auto-registered child devices are always linked to the main device as its immediate children.
54+
If your device fleet has a nested hierarchy of child devices spanning multiple levels, then auto-registration must be turned off,
55+
to prevent all child devices(even the nested ones) wrongly getting auto-registered as immediate children of the main device.
56+
57+
Auto-registration can be turned off with a configuration setting as follows:
58+
59+
```sh
60+
tedge config set agent.entity_store.auto_register false
61+
```
62+
63+
After this configuration change, the `tedge-agent` must be restarted for it to take effect.
64+
65+
Turning off auto-registration can be beneficial in certain other scenarios as well:
66+
- If the default topic scheme does not match your fleet, and you'd like to use your own [custom topic scheme](../../contribute/design/mqtt-topic-design.md#using-custom-identifier-schemas) for your entities (e.g: `factory1/floor1/painting/robot1`)
67+
- You still want to use the default topic scheme, but need more control over the metadata of the entities that are registered,
68+
like registering every entity with an explicit `@id` or having the entities registered with some initial twin data.
69+
70+
:::caution
71+
Combining auto-registration with explicit registration using the MQTT API is highly discouraged,
72+
as it can lead to unexpected results like nested child devices getting auto-registered as immediate child devices,
73+
or services getting registered under the wrong parent device.
74+
If explicit registration is required in a deployment where auto-registration is already enabled,
75+
using the HTTP registration API is recommended, before any telemetry data is published by those clients.
76+
:::

0 commit comments

Comments
 (0)