|  Developer
Updated on July 15, 2022

compareNumbers

  • This event arises when the of an item or expression corresponds to a condition set in this block. For example, if the is , is equal to and item value is , then an event arises. If the condition is , then the event arises only once after the threshold was exceeded. For example, if the item value is and after that item value becomes , then an event arises. When item value becomes the event doesn’t arise. The event will arise again when the threshold is exceeded again. Similar situation is for other comparators ( , , ).
  • An or type can be used instead of a constant item value.
Edit
Field Type Required Description
blockOptions.method.args.item
blockOptions.method.args.expression
string + Argument declaration of a value source for the left part of the comparison operator. For the source the value is item ID. For the source the value is the expression name. The name of the source should have a corresponding block with a matching source name.
blockOptions.method.args.value string + Argument declaration of item value. The value should be in block with name.
blockOptions.method.args.comparator string + Argument declaration of comparator state. The value should be in block with name. Possible comparators are , , , , , .
Edit
Edit
				
					"when" : [
    {
        "blockType":"when",
        "blockOptions":{
            "method":{
                "name":"compareNumbers",
                "args":{
                    "item":"item",
                    "comparator":"comparator",
                    "value":"value"
                }
            }
        },
        "fields":[
            {
                "name":"item",
                "type":"item",
                "value":"5de64f6a70c7be0541cc0853"
            },
            {
                "name":"comparator",
                "type":"string",
                "value": ">"
            },
            {
                "name":"value",
                "type":"int",
                "value": 51
            }
        ]
    },
    {
        "blockType":"when",
        "blockOptions":{
            "method":{
                "name":"compareNumbers",
                "args":{
                    "item":"item",
                    "comparator":"comparator",
                    "value":"value"
                }
            }
        },
        "fields":[
            {
                "name":"item",
                "type":"item",
                "value":"5de64f6a70c7be0541cc0854"
            },
            {
                "name":"comparator",
                "type":"string",
                "value": "<="
            },
            {
                "name":"value",
                "type":"float",
                "value": 51.55
            }
        ]
    }
]				
			
Edit

Use an expression value to compare with an item updated value. The event will raise in a situation when an item value meet the expression value: – the item value is changed; – the expression value is changed.

				
					"when" : [
    {
        "blockType": "when",
        "blockOptions":{
            "method": {
                "name": "compareNumbers",
                "args": {
                    "item": "item",
                    "comparator": "comparator",
                    "value": "value"
                }
            }
        },
        "fields": [
            {
                "name": "item",
                "type": "item",
                "value": "5de64f6a70c7be0541cc0853"
            },
            {
                "name": "comparator",
                "type": "string",
                "value": ">"
            },
            {
                "name": "value",
                "type": "expression",
                "value": "expressionName"
            }
        ]
    }
]				
			
See Scenes expression related commands for detail on creating expressions.
Edit

Compare value of an expression with name “expressionLeft” with a value of an expression with name “expressionRight”. The event will raise when value of “expressionLeft” becomming greater than value of “expressionRight”. Event checked whenever values of “expressionLeft” or “expressionRight” are changed.

				
					"when" : [
    {
        "blockType": "when",
        "blockOptions":{
            "method": {
                "name": "compareNumbers",
                "args": {
                    "expression": "expression",
                    "comparator": "comparator",
                    "value": "value"
                }
            }
        },
        "fields": [
            {
                "name": "expression",
                "type": "expression",
                "value": "expressionLeft"
            },
            {
                "name": "comparator",
                "type": "string",
                "value": ">"
            },
            {
                "name": "value",
                "type": "expression",
                "value": "expressionRight"
            }
        ]
    }
]