How-To Guides
DeviceHub Guides

Organize Device and Tag Data by Using Metadata

17min
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 user scenario 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 step 1 connect devices 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 device 1 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 connect a device docid\ ish7bqhzxswtdx8vbnszb device 2 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 connect a device docid\ ish7bqhzxswtdx8vbnszb device 3 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 connect a device docid\ ish7bqhzxswtdx8vbnszb device 4 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 connect a device docid\ ish7bqhzxswtdx8vbnszb step 2 add tags 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 plc 1 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 plc 2 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 plc 3 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 plc 4 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 step 3 view data you can now view the data from the devices and tags in litmus edge through the flows manager docid bvxnzlgo8fsoglib4o l view data in 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 create a flow docid\ veyyte7xdcangglzbqya0 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 t he 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 view payload data review the payload data from the debug window for each devicehub device plc 3 { "success" true, "datatype" "int64", "timestamp" 1683901823577, "registerid" "dbe0c6d2 a91d 49d1 9cb7 dbf3c6d9c919", "value" 1, "deviceid" "7c01e851 fe46 463a 90ec 98aa3f12be09", "tagname" "air pressure 1", "devicename" "plc 3", "description" "", "metadata" { "country" "us", "device location" "north wing", "city" "cleveland", "category" "pressure" } } plc 3 { "success" true, "datatype" "int64", "timestamp" 1683901823577, "registerid" "e2a6a9e3 697b 436d 8682 866950bf96ac", "value" 1, "deviceid" "7c01e851 fe46 463a 90ec 98aa3f12be09", "tagname" "air pressure 2", "devicename" "plc 3", "description" "", "metadata" { "device location" "north wing", "city" "cleveland", "country" "us", "category" "pressure" } } plc 1 { "success" true, "datatype" "int64", "timestamp" 1683901824688, "registerid" "7425f365 9d97 4b6c bb01 dccafc04f383", "value" 1, "deviceid" "c9c3f3df 954f 4233 834c 4b381741357c", "tagname" "temperature 1", "devicename" "plc 1", "description" "", "metadata" { "device location" "south wing", "city" "chicago", "country" "us", "category" "temp" } } plc 1 { "success" true, "datatype" "int64", "timestamp" 1683901824688, "registerid" "c35cb204 5a00 4753 b7af f1d6059a2e1b", "value" 1, "deviceid" "c9c3f3df 954f 4233 834c 4b381741357c", "tagname" "temperature 2", "devicename" "plc 1", "description" "", "metadata" { "country" "us", "category" "temp", "device location" "south wing", "city" "chicago" } } plc 2 { "success" true, "datatype" "int64", "timestamp" 1683901825029, "registerid" "008a21c1 fe0a 41ec 83a6 48c60831c11c", "value" 1, "deviceid" "5d4ef199 ac0d 4510 839e f3256650d0b8", "tagname" "temperature 1", "devicename" "plc 2", "description" "", "metadata" { "device location" "east wing", "city" "chicago", "country" "us", "category" "temp" } } plc 2 { "success" true, "datatype" "int64", "timestamp" 1683901825029, "registerid" "c083de09 f6bd 428a 9710 6579adb03f9c", "value" 1, "deviceid" "5d4ef199 ac0d 4510 839e f3256650d0b8", "tagname" "air pressure 1", "devicename" "plc 2", "description" "", "metadata" { "city" "chicago", "country" "us", "category" "pressure", "device location" "east wing" } } plc 4 { "success" true, "datatype" "int64", "timestamp" 1683901827473, "registerid" "0d918230 21cd 4d89 9cf2 f4e3550b599b", "value" 0, "deviceid" "629145eb 2549 4bc1 8ecb acd86bc44061", "tagname" "temperature 1", "devicename" "plc 4", "description" "", "metadata" { "country" "canada", "device location" "north wing", "city" "toronto" } } plc 4 { "success" true, "datatype" "int64", "timestamp" 1683901827473, "registerid" "7782779e 1582 4773 ab02 0a8ce8bd3597", "value" 0, "deviceid" "629145eb 2549 4bc1 8ecb acd86bc44061", "tagname" "air pressure 1", "devicename" "plc 4", "description" "", "metadata" { "device location" "north wing", "city" "toronto", "country" "canada", "category" "pressure" } }