Organize Device and Tag Data by Using Metadata
When configuring DeviceHub devices and tags, you have the option of adding metadata, which allows you to define key-value pair data for the device output payload. The metadata can then be used to find, use, and reuse particular instances of data.
Some examples where using metadata would be beneficial include the following:
- Device category metadata organizes devices.
- Tag type metadata organizes tag categories.
- Plant Floor ID metadata organizes different areas of a production site.
- Location metadata organizes devices and plants across multiple worldwide sites.
For this user scenario, you will use device and tag metadata to organize your data using the following parameters:
- The country and city the device is located in. In a real-life scenario, you may be using multiple Litmus Edge instances across different locations that are managed by Litmus Edge Manager.
- The location (wing area) of the devices within each plant.
- The category for each tag.
You will create four devices, with two tags each, totaling eight tags.
You will first connect all relevant devices in DeviceHub.
To connect devices:
- Navigate to DeviceHub. The Devices pane opens.
Click the Connect a Device box. The Connect Device dialog box appears.
- Click the Device Type drop-down list and select Simulator.
- Click the Driver Name drop-down list, and select Generator.
Configure the following four devices.
- Name: PLC_1
- Meta Data: Select checkbox.
- Key/Value pair 1
- Key: Country
- Value: US
- Key/Value pair 2
- Key: City
- Value: Chicago
- Key/Value pair 3:
- Key: Device_Location
- Value: South_Wing
- Enable Alias Topics: To view the topic with an alias name instead of in raw format, select this checkbox. For Litmus Edge version 3.5.2 and later, it is selected by default. Learn more about Alias Topics.
- Name: PLC_2
- Meta Data: Select checkbox.
- Key/Value pair 1
- Key: Country
- Value: US
- Key/Value pair 2
- Key: City
- Value: Chicago
- Key/Value pair 3
- Key: Device_Location
- Value: East_Wing
- Enable Alias Topics: To view the topic with an alias name instead of in raw format, select this checkbox. For Litmus Edge version 3.5.2 and later, it is selected by default. Learn more about Alias Topics.
- Name: PLC_3
- Meta Data: Select checkbox.
- Key/Value pair 1
- Key: Country
- Value: US
- Key/Value pair 2
- Key: City
- Value: Cleveland
- Key/Value pair 3
- Key: Device_Location
- Value: North_Wing
- Enable Alias Topics: To view the topic with an alias name instead of in raw format, select this checkbox. For Litmus Edge version 3.5.2 and later, it is selected by default. Learn more about Alias Topics.
- Name: PLC_4
- Meta Data: Select checkbox.
- Key/Value pair 1
- Key: Country
- Value: Canada
- Key/Value pair 2
- Key: City
- Value: Toronto
- Key/Value pair 3
- Key: Device_Location
- Value: North_Wing
- Enable Alias Topics: To view the topic with an alias name instead of in raw format, select this checkbox. For Litmus Edge version 3.5.2 and later, it is selected by default. Learn more about Alias Topics.
You can now add tags to the devices you created. For this user scenario, the tags will be used to capture air pressure and temperature values, and each device can have multiple tags for each measurement.
To add tags:
- Navigate to DeviceHub > Tags.
From the Tags pane, click Add Tag, and then select Add Tag. The Add Tag dialog box appears.
- Click the Select a Device field, and then select the first device to add tags to.
Add the following eight tags.
Tag 1
- Name: S - Random value generator
- Value Type: int64
- Polling Interval: Enter 5. This is the time interval in seconds that the tag will be polled for data.
- Tag Name: Temperature_1
- Meta Data: Select checkbox.
- Key/Value pair
- Key: Category
- Value: Temp
Tag 2
- Name: S - Random value generator
- Value Type: int64
- Polling Interval: Enter 5. This is the time interval in seconds that the tag will be polled for data.
- Tag Name: Temperature_2
- Meta Data: Select checkbox.
- Key/Value pair
- Key: Category
- Value: Temp
Tag 1
- Name: S - Random value generator
- Value Type: int64
- Polling Interval: Enter 5. This is the time interval in seconds that the tag will be polled for data.
- Tag Name: Temperature_1
- Meta Data: Select checkbox.
- Key/Value pair
- Key: Category
- Value: Temp
Tag 2
- Name: S - Random value generator
- Value Type: int64
- Polling Interval: Enter 5. This is the time interval in seconds that the tag will be polled for data.
- Tag Name: Air_Pressure_1
- Meta Data: Select checkbox.
- Key/Value pair
- Key: Category
- Value: Pressure
Tag 1
- Name: S - Random value generator
- Value Type: int64
- Polling Interval: Enter 5. This is the time interval in seconds that the tag will be polled for data.
- Tag Name: Air_Pressure_1
- Meta Data: Select checkbox.
- Key/Value pair
- Key: Category
- Value: Pressure
Tag 2
- Name: S - Random value generator
- Value Type: int64
- Polling Interval: Enter 5. This is the time interval in seconds that the tag will be polled for data.
- Tag Name: Air_Pressure_2
- Meta Data: Select checkbox.
- Key/Value pair
- Key: Category
- Value: Pressure
Tag 1
- Name: S - Random value generator
- Value Type: int64
- Polling Interval: Enter 5. This is the time interval in seconds that the tag will be polled for data.
- Tag Name: Air_Pressure_1
- Meta Data: Select checkbox.
- Key/Value pair
- Key: Category
- Value: Pressure
Tag 2
- Name: S - Random value generator
- Value Type: int64
- Polling Interval: Enter 5. This is the time interval in seconds that the tag will be polled for data.
- Tag Name: Temperature_1
- Meta Data: Select checkbox.
- Key/Value pair
- Key: Category
- Value: Temp
You can now view the data from the devices and tags in Litmus Edge through the Flows Manager.
- Navigate to DeviceHub. The Devices pane opens.
For the PLC_1 device tile, open the menu and copy the device topic name. Store the topic name somewhere for use later. The ">" indicates a wildcard character, so the topic name applies to all tags for the device.
- Copy and store the device topic names for all other devices.
- Navigate to Flows Manager.
For a Flows Manager, click the Go To Flow Definition icon. The Flow canvas opens in a new browser tab.
On the Flow canvas, drag four DataHub Subscribe nodes and four debug nodes onto the canvas. Then, connect the nodes.
- Double-click the first DataHub subscribe node. The Edit DataHub Subscribe node dialog box appears.
- In the Topic field, paste the wildcard topic name for the device copied in step 2.
- If needed, configure the Datahub Subscribe connection. See the Configure Connector Nodes section to learn more.
- In the Name field, enter PLC_1.
- Click Done.
Continue configuring the other three DataHub Subscribe nodes for the other devices.
- Click Deploy.
Expand the message window beneath the flow to view debug messages.
Click the Debug icon.
Make sure the four debug nodes are activated.
- View the data in the debug window. The payload below shows data from each tag in each of the four devices. The device and tag metadata is included at the end of each payload item.
Review the payload data from the debug window for each DeviceHub device.