thin-edge / thin-edge.io

The open edge framework for lightweight IoT devices
https://thin-edge.io
Apache License 2.0
222 stars 55 forks source link

New tedge twin (inventory) MQTT topic #2279

Closed reubenmiller closed 1 year ago

reubenmiller commented 1 year ago

Is your feature request related to a problem? Please describe.

Support new tedge telemetry type called twin (in Cumulocity IoT this is called inventory managed object updates) to add json data to the device, child device or service's digital twin in the Cloud.

Describe the solution you'd like

New topic following the tedge MQTT V1 interface to allow users to publish additional information to the entity (e.g. device, child device or service).

Topic name

te/{identity}/twin/<type>

Payload (json, retain=true)

{
    "family": "Debian",
    "version": 11
}

MQTT messages published to te/{identity}/twin/<type> should be published with the retained flag to allow other components to more easily observe the information.

Cloud mapper initialization (to be validated)

When the tedge-mapper starts up for a given cloud, it should run the following routine to process the initial values after any registration process has finished:

  1. Read the inventory.json file, load the values into an in-memory model
  2. Subscribe to the data topic using the MQTT topic pattern {identifier}/twin/+ and merge the results. The values received via MQTT take precedence over any duplicated values from the inventory.json file
  3. Publish the inventory changes to the relevant cloud in one message (if possible)
  4. Process all subsequent messages received on the {identifier}/twin/+ MQTT topic as single message to the relevant cloud

Open questions

Describe alternatives you've considered

Additional context

A draft PR has already been created to include the following items to assist with the development:

Related tickets

didier-wenzek commented 1 year ago

@gligorisaev See this comment for the testing plan: https://github.com/thin-edge/thin-edge.io/pull/2280#issuecomment-1772255554

gligorisaev commented 1 year ago

QA has thoroughly checked the feature and here are the results: