|  Developer
Updated on December 2, 2022

function/for

  • The FOR function controls periods child events spend in their state. There are two possible variants: and .
Field Type Required Description
blockOptions.method.args.blocks string + The argument declaration of field. The name is “blocks”. The type is “blocks”. The field could contain several when blocks.
blockOptions.method.name string + Should contain the value .
blockOptions.function object + Definition of a function to apply to children.
blockOptions.function.for object Settings of a FOR function.
blockOptions.function.for.method enum(, ) + A FOR function method to apply.
blockOptions.function.for.seconds int + A period FOR function should control.

NOTE: The FOR function state is not saved between the scene service restarts, so, the function operator should not be used to handle large periods of time like hours and days. It is only intended to handle periods in seconds.

function/for/less

  • The function for/less is intended to ignore too-long transitions between the and the state of child events.
  • The for/less sets the interval duration in seconds.
  • If a child event becomes , this function saves the timestamp of state transition. The state of a function stays . If a child event becomes , the function for/less checks whether an interval between the state transitions was less than the interval set as a function for/less condition.
  • If it is less than that interval, the function operator becomes , and then, immediately, becomes . Otherwise, if the interval between the transitions is greater than the For/Less function specified, the operator stays .

function/for/least

    The function for/least is intended to ignore transitions that occur too fast. The for/least sets the interval duration in seconds. If a child event becomes , the function saves the transition timestamp. If a child event becomes , it immediately sets a function in that same state (). If a child event stays for the time specified in a for/least function conditions, the function becomes itself.

    Only after that the scene state can be notified as .

This feature is available since advanced_scenes/1.18.

Examples:

function/for/less

				
					{
   "blockOptions":{
      "method":{
         "args":{
            "blocks":"blocks"
         },
         "name":"function"
      },
     "function":{
         "for":{
             "method":"less",
             "seconds":10
         }
      }
   },
   "blockType":"when",
   "fields":[
       {
           "name":"blocks",
           "type":"blocks",
           "value": [
               __WHEN_BLOCK__, __WHEN_BLOCK__
           ]
       }
   ]
}				
			

function/for/least

				
					{
   "blockOptions":{
      "method":{
         "args":{
            "blocks":"blocks"
         },
         "name":"function"
      },
     "function":{
         "for":{
             "method":"least",
             "seconds":10
         }
      }
   },
   "blockType":"when",
   "fields":[
       {
           "name":"blocks",
           "type":"blocks",
           "value": [
               __WHEN_BLOCK__, __WHEN_BLOCK__
           ]
       }
   ]
}				
			

Here, the stands for any valid when block, like a final event or a logical operator.