Data Explorer: Filtering for specific device attributes
Data can be filtered for specific attributes. This example shows how the status attribute of a Thing can be filtered.
For instance, the device contains the device attribute status to indicate whether a setting was enabled or disabled at the time. Adjust the set parameters in the query template as follows:
Add the following code block to the template definition:
To filter for a specific parameter with a certain value, add $match at the end of the query.
{ "$group":{ _id: "$_id", "MetaData": {$first:"$metaData"}, "Payload": {$first:"$payload"}, "DataModifiedAt": {$first:"$metaData.eventStartTs"}, "HistoryModifiedAt": {$first: "$historyData.snapshots.modified"}, "VersionHistory": {$first:"$historyData"}, "VersionHistoryProperties": {$first:"$historyData.snapshots.features.general.properties"}, <#if attribute??> "${attribute}": {$first: "$historyData.snapshots.features.general.properties.${attribute}"}</#if> } }, { "$match": { "VersionHistory.snapshots.features.general.properties.status": "${status}" } }, { "$limit": 1000 }