|  Developer
Updated on February 14, 2023

inArray

  • Checks if the item’s or expression’s value is present/absent in an array.
  • When the data source is a device/item group, the event is stateless. It arises every time the condition is true, no matter which value of an event was previously. See Stateless comparison.
  • This feature is available since the version. This method might be used for all types, which can be compared for equality.
  • The scene is triggered when the condition of the specified operation is satisfied.
  • operation checks if the item’s or expression’s value is present in the array.
  • operation checks if the item’s or expression’s value is absent in the array.
Edit
Field Type Required Description
blockOptions.method.args.item
blockOptions.method.args.expression
item
expression
+ Id of an item or expression whose value to check.
blockOptions.method.args.deviceGroup string Value source will be used as an operand to search in the array. References a device group by its ID. The parameter is required.
blockOptions.method.args.itemGroup string Value source will be used as an operand to search in the array. References an item group by its ID. The parameter is required.
blockOptions.method.args.value array + An array of values to search in. Should contain at least 2 elements.
blockOptions.method.args.operation string The operation that determines which check will be performed. Possible values: , . Default is .
Edit
Internal error code Message Data
SCENE_WRONG_WHEN_BLOCK inArray: empty id of an item ezlo.scenes.block.when.wrong
SCENE_WRONG_WHEN_BLOCK inArray: “value” field is empty ezlo.scenes.block.when.wrong
SCENE_WRONG_WHEN_BLOCK inArray: cannot create valid value: [REASON] ezlo.scenes.block.when.wrong
SCENE_WRONG_WHEN_BLOCK inArray: value should be an array, actual type: [TYPE] ezlo.scenes.block.when.wrong
SCENE_WRONG_WHEN_BLOCK inArray: unknown operation: [OPERATION] ezlo.scenes.block.when.wrong
SCENE_WRONG_WHEN_BLOCK inArray: array should have at least 2 values, for comparing against a single value use “isItemState” method ezlo.scenes.block.when.wrong
Edit
Edit

Example 1: inArray operation of an item:

				
					{
    "blockType": "when",
    "blockOptions": {
        "method": {
            "name": "inArray",
            "args": {
                "item": "item",
                "operation": "operation",
                "value": "value"
            }
        }
    },
    "fields": [
        {
            "name": "item",
            "type": "item",
            "value": "5de64f6a70c7be0541cc0853"
        },
        {
            "name": "operation",
            "type": "string",
            "value": "not_in"
        },
        {
            "name": "value",
            "type": "array.string",
            "value": [ "a", "b", "c" ]
        }
    ]
}				
			
Edit

Example 2: inArray operation of any item that matches the device/item group with operation type:

Define a device group, define an item group, make a condition block to make a inArray operation of an hub.item.updated broadcast with the operation value. The operation is stateless. It doesn’t have information about previous value of any item in the group.

Operation type: stateless

				
					{
    "blockType":"when",
    "blockOptions":{
        "method":{
            "name":"inArray",
            "args":{
                "deviceGroup":"deviceGroup",
                "itemGroup":"itemGroup",
                "operation": "operation",
                "value": "value"
            }
        }
    },
    "fields":[
        {
            "name":"deviceGroup",
            "type":"device_group",
            "value":"5de64f6a70c7be0541cc0853"
        },
        {
            "name":"itemGroup",
            "type":"item_group",
            "value":"5de64f6a70c7be0541cc0854"
        },
        {
            "name": "operation",
            "type": "string",
            "value": "not_in"
        },
        {
            "name": "value",
            "type": "array.string",
            "value": [ "a", "b", "c" ]  
        }
    ]
}				
			

Available since: Group operations filtering is available since .