Bosch IoT Device Management - will be discontinued by mid 2024

Working with tags

Tags facilitate the grouping of and searching for devices. A device may have multiple tags attached to it, meaning that in such cases it will be included in multiple tag groups.

The examples below demonstrate how you can create a tag and list created tags, as well as how you can tag a device and list tagged devices.

Create a tag

Execute the following code to create a tag with a particular name, such as myTag:

deviceInventory.createTag(Parameters.newBuilder().name(tagName).build());

List tags

List all existing tags grouped in pages of 10 elements each:

deviceInventory.tags(10);

Tag a device

Attach the newly created tag from the example above to a device with a particular deviceId:

deviceInventory.tagDevice(deviceId, tagName);

List tagged devices - using a tag object

List all devices which have been tagged with myTag and have been set a particular attribute, for example myAttribute:

tag.devices(
 
Filter.newBuilder()
 
.query("exists(attributes/myAttribute)")
 
.build(),
 
/* Page size */
 
10
 
);

List tagged devices - using DeviceInventory and ready-to-use filters in Criteria class

List all devices tagged with myTag:

deviceInventory.devices(
 
Filter.newBuilder()
 
.query(Criteria.hasTag(tagName))
 
.build(),
 
10
 
);

Tags can have attributes, described in more detail in Working with attributes.