thin-edge/thin-edge.io

Add `@id` to entity metadata when c8y-mapper generates external ID

Closed this issue · 2 comments

Is your feature improvement request related to a problem? Please describe.
When a new entity is created, c8y-mapper generates its external ID.

In this example, TST_burn_sunny_confirmation:device:child-1234 is the external ID generated by c8y-mapper. This ID is currently stored in the entity store of c8y-mapper's converter. As long as one component has an access to the entity store (= must be a part of c8y-mapper's converter), it can consume the external ID.

[te/device/child-1234//] {"@type":"child-device"}
[c8y/s/us] 101,TST_burn_sunny_confirmation:device:child-1234,TST_burn_sunny_confirmation:device:child-1234,thin-edge.io-child

However, for other components, getting the external ID is fairly not possible, although such external ID is necessary to publish JSON over MQTT (for both main and child devices) and SmartREST (for child devices) messages as part of the topic name.

I want a solution to get to know the entity's external ID in an easy way.

Describe the solution you'd like
During the entity registration, c8y-mapper re-publishes the metadata message with @id field when it's generated by mapper. By using the example above again, the last message should be added so that all components can know the generated external ID.

[te/device/child-1234//] {"@type":"child-device"} # user send
[c8y/s/us] 101,TST_burn_sunny_confirmation:device:child-1234,TST_burn_sunny_confirmation:device:child-1234,thin-edge.io-child # c8y registration
[te/device/child-1234//] {"@type":"child-device", "@id":"TST_burn_sunny_confirmation:device:child-1234"} # mapper re-publish

If @id is provided by user in the initial registration message, c8y-mapper will not do anything extra.

Describe alternatives you've considered

Additional context
While I am working in availability monitoring actor, I got a problem how to know devices' external IDs on Cumulocity.

Resolved by #2925

Feature checked with:

1.1.1-113-g82732a9e21

Test Case: tests/RobotFramework/tests/cumulocity/registration/registration_lifecycle.robot

The added test steps are covering the implemented feature