Star

Reference Documentation

Design docs, concept definitions, and references for APIs and CLIs.

Device Attributes Filter

Overview

This component allows to filter incoming messages by attributes of the device. This filter is very useful if you want to apply rule only to certain sub-set of your device. Filter expression is a javascript expression and basically defines this sub-set. You are able to use any attribute types.

Configuration

You are able to write boolean javascript expression using following bindings:

If you are not sure that certain attribute is present, you can add check it’s type for undefined. For example, filter below will match if client-side attribute ‘firmware_version’ is set and equal to ‘1.0.0’

typeof cs.firmware_version !== 'undefined' && cs.firmware_version === '1.0.0' 

Example

Assuming following device attributes and their types - firmware_version - client-side - country - client-side - subscription_plan - shared - balance - server-side

Following filter will match all premium subscription devices with positive balance that are located in USA with firmware version equal to 1.1.0

cs.firmware_version=='1.1.0' && cs.country=='USA' && shared.subscription_plan=='premium' && ss.balance > 0

If you are not sure that all attributes are present for your device, you should use following syntax that adds all necessary “null” checks

typeof cs.firmware_version !== 'undefined' && 
typeof cs.country !== 'undefined' && 
typeof shared.subscription_plan !== 'undefined' && 
typeof ss.balance !== 'undefined' && 
cs.firmware_version=='1.1.0' && cs.country=='USA' && shared.subscription_plan=='premium' && ss.balance > 0