Smart REST static template 101 creates a child device with unexpected external id

Product/components used and version/fix level:

Cumulocity IoT 1020.296.0

Detailed explanation of the problem:

As mentioned in the title we use Smart REST to create devices. In particular we already created a root device and we are now creating some child devices.

We are able to create a child device but the external id bounded to that device is not what we expect.

Indeed from the docs about child device creation is stated that:

[…] an externaId for the child will be created with type c8y_Serial and the value a combination of the serial of the root device and the unique child ID.

The value of the external id of the resulting child device is just the id included in the mqtt message.

The code:

String childDeviceName = "childSensor";
		String childDeviceType = "dac_sensor";
		String childId = "1";
		String staticTemplateCode = "101";

		client.publish("s/us",
				(staticTemplateCode + "," + childId + "," + childDeviceName + "," + childDeviceType).getBytes(), 2,
				false);

Should I manually create the combination of parent and child id?

Error messages / full error message screenshot / log file:

Question related to a free trial, or to a production (customer) instance?

Customer instance

I think the documentation is misleading here.
When creating a device using 100 SmartREST template the clientID of the MQTT client is used as an external ID.
For child devices you must explicitly name the unique ID of the children. If you want to combine the clientID + child device ID you can do so. Still I would suggest to use something unique like serial number also for the child device when available and not “1,2,3” etc. :wink:

1 Like