The following requests use the $filter function. It is a powerful tool to query only what you are looking for. Below are the operators you can define with the filter function.
Operator |
Description |
Comment |
---|---|---|
eq |
Equal |
Performs an exact match on that field |
ne |
Not equal |
Matches on non-matching values |
gt |
Greater than |
Matches when the field is greater than the value |
ge |
Greater or equal |
Matches when the field is greater than or equal to the value |
lt |
Less than |
Matches when the field is less than the value |
and |
Logical and |
|
or |
Logical or |
|
contains |
Matches anything that contains the value |
|
startswith |
Matches on anything that starts with the value |
|
endswith |
Matches on anything that ends with the value |
Filters with the 'contains', 'startswith', or 'endswith' operators do not work for
properties that are select lists. To verify whether a property is a select list, run
the request 02.04 Plant annotations and search for the property in the results. In the example below, the motor property
'ItemStatus' is a select list, whereas the 'Description' and 'ItemTypeName' properties
are not.
Filter Item Tag
In request 03.06 Specific motor, you already saw how a filter works. The following request filters for a specific plant item with item tag ‘M-2’ and additionally queries the number of plant items retrieved using the $count operator.
-
Select the request 04.01 Filter (Plant Item) eq Item Tag and click Send.
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/PlantItems?$count=true&$filter=ItemTag eq 'M-2'
The response returns a single item (Motor) with the requested item tag value.
Filter Control Stations with Note ne ''
This request gets all the control stations that include a note. The request also includes the number of items.
-
Select the request 04.02 Filter (Control Stations) - with Note + count and click Send.
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/ControlStations?$count=true&$filter=Note ne ''
The results show the number of control stations that are returned with the requested filter.
-
Now change the ‘ne’ parameter in the request to ‘eq’ and resend the request. Note the number of control stations returned.
-
Next, remove the filter condition completely from the request and resend. The total number of control stations returned should be equal to the sum of control stations returned by the previous two requests.
Filter starts with
This request gets all the plant items whose Item Type Name property value starts with the string ‘Signal’. The request also includes the number of items.
-
Select the request 04.03 Filter starts with and click Send.
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/PlantItems?$count=true&$filter=startswith(ItemTypeName,'Signal')
Filter ends with
This request gets all the plant items whose Item Type Name property value ends with the string ‘Run’. The request also includes the number of items.
-
Select the request 04.04 Filter ends with and click Send.
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/PlantItems?$count=true&$filter=endswith(ItemTypeName,'Run')
Filter contains
This request gets all the motors whose Item Tag property value contains the string ‘123’. The request also includes the number of items and some selected properties.
-
Select the request 04.05 Filter contains and click Send.
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/Motors/Com.Ingr.SEL.V2.WEBAPISITE001.PLANT001.Motor/?$count=true&$select=Id,ItemTag,MotorRatedPower,RatedVoltage,aabbcc_code&$filter=contains(ItemTag,'mo')
Filter using logical or
This request gets all the control stations that contain 'CS-16' or 'TESTCS' in their name.
-
Select the request 04.06 Filter using logical OR and click Send.
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/Instruments/Com.Ingr.SEL.V2.WEBAPISITE001.PLANT001.ControlStation/?$count=true&$select=ItemTag,ItemTypeIdentifier,SP_CircuitID,aabbcc_code&$filter=contains(ItemTag,'CS-16') or contains(ItemTag,'TESTCS')
Motors filtered by equipment type
This request gets all the motors with a rated voltage of 220 V. The request also includes the number of items and some selected properties.
-
Select the request 04.07 Filter (Motor) eq Item EquipmentType + count + selected properties and click Send.
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/Motors/Com.Ingr.SEL.V2.WEBAPISITE001.PLANT001.Motor/?$count=true&$select=Id,ItemTag,MotorRatedPower,RatedVoltage,aabbcc_code&$filter=RatedVoltage eq '220 V'
Filter items using a predefined filter and additional filter criteria
This option is available from Smart Electrical Web API 2.1.3 and later. This request is the equivalent of applying a base filter in the EDE with additional filter criteria. In the example below, the base filter Motor M- (represented in the request by the Filter_Id value) specifies motors with names that begin with the string M-, on top of which a filter for getting motors with a rated voltage of 220 V is applied.
-
Obtain the Filter_Id of the base filter by running one of the following requests:
-
To obtain all Filter_Id values:
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/Filters
-
To obtain a Filter_Id value based on a specific filter name, run a request such as the following:
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/Filters
?$filter=Name eq 'Motor M-'Example result:
-
-
Run the request using the Filter_Id obtained in the previous step:
-
The following request returns all motors that comply with the base filter only:
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
Filters('DACAE2C76D6944E1878D04869397BF61') -
The following request is equivalent to applying the base filter with additional criteria as shown in the UI above:
https://apiservername.domain.com/WebApi/SEL/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
Filters('DACAE2C76D6944E1878D04869397BF61')?$filter=RatedVoltage eq '220 V'
-