|  Developer
Updated on June 23, 2022

hub.scenes.scripts.add

  • Version: 1.0
  • Classes: UI
  • Title: Scene manager categories
  • Description: Add/load a new script snippet for using in scenes
Edit
Field Type Required Description
code string + Lua code snippet to be run within a scene (Max 5 kb for Linux and 1 kb for Atom)
name string Title for the script snippet ( Max 30 characters )
Edit
Field Type Required Description
_id string + Unique id of an added/loaded script snippet
Edit
Code Message Data
-32600 Wrong params,
Edit
Here is it an example of usage:
Edit
				
					{
   "id":"_ID_",
   "jsonrpc":"2.0",
   "method":"hub.scenes.scripts.add",
   "params":{
      "name":"Switch on all lights",
      "code": "require \"core\"\n local items = core.get_items()\n if items then \n \n for _, item in ipairs( items ) do\n core.set_item_value( item._id, true ) \n  end\n end"
   }
}				
			
Edit
				
					{
    "error": null,
    "id": "_ID_",
    "result": {
        "_id": "5cf0dc8c7f000068d223e88a"
    }
}