|  Developer
Updated on March 28, 2023

toggleValue

  • Action to toggle boolean items and expression variables to the opposite state.
  • This feature is available since version
  • If action is called, the value should set to an opposite one:
  • 1.1 item = { type: boolean, value: any }: toggle( item ) -> item.value = not( item.value )
  • 1.2 item = { type: int, value = 0 } toggle(item) -> item.value = ( item.value == 0 ? 1 : 0 )
  • The same for variable expressions of types ‘bool’ and ‘int’
  • 2.1 variable = { type: boolean, value: any }: toggle( variable ) -> variable.value = not( variable.value )
  • 2.2 variable = { type: int, value = 0 } toggle( variable ) -> variable.value = ( variable.value == 0 ? 1 : 0 )
Edit
Field Type Required Description
blockOptions.method.args.source string, enum(“item”, “expression”) + Data source is an item OR an expression
Edit
Data Internal error code Message
rpc.params.invalid.{FIELD} BAD_PARAMS Wrong params, {FIELD}
scenes.action.type.mismatch SCENE_ACTION_TYPE_MISMATCH Action block has incompatible value types
scenes.item.does.not.exist SCENES_ITEM_DOES_NOT_EXIST Item does not exist
scenes.expression.does.not.exist SCENES_EXPRESSION_DOES_NOT_EXIST Expression does not exist
Edit
Edit
  • Item value:
				
					{
   "blockOptions":{
      "method":{
         "args":{
            "source":"item"
         },
         "name":"toggleValue"
      }
   },
   "blockType":"then",
   "fields":[
      {
         "name":"item",
         "type":"item",
         "value" : "897607_32771_1"
      }
   ]
}]
}				
			
Edit
  • Expression value:
				
					{
   "blockOptions":{
      "method":{
         "args":{
            "source":"expression"
         },
         "name":"toggleValue"
      }
   },
   "blockType":"then",
   "fields":[
      {
         "name":"expression",
         "type":"expression",
         "value":"variableName"
      }
   ]
}]
}