|  Developer
Updated on June 23, 2022

hub.scenes.create

  • Version: 1.0
  • Classes: UI
  • Title: Scene manager categories
  • Description: Create a new scene.
Edit
Field Type Required Description
enabled boolean + enable or disable scene
group_id string group identifier, Scenes could be unite to the group for enabling/disabling
name string + scene name. Maximum name length is 25 characters.
meta JsonObject Scene metadata information. Intended to save data needed for user interfaces.
parent_id string room identifier for that it was created. If is not set then it should have empty value for both hub.scenes.list and hub.scenes.get
then JsonArray + An array of then blocks
else JsonArray An array of else blocks
thenGroups JsonObject A dictionary of action groups
elseGroups JsonObject + A dictionary of action groups
when JsonArray + Array of the blocks defining when the scene should be executed
exceptions JsonArray Array of the blocks for exceptions in actions
user_notifications JsonArray Array of the user IDs for notification broadcasts making. This is array of strings.
house_modes StringArray Array of house mode IDs. If this array is added then it makes new condition along with block and this condition is connected with block by logical AND operator. So if one of arises and one of these house modes is set then will be executed.
exec_policy string It is execution policy of scene. There is policy of block ( see description of then blocks ). The block policy can have next states: – result of execution each block should checked and scene should be failed in case if block is failed; – result of execution each block should be ignored and checked only in the end of scene execution. If any action was failed than partially_finished status. If all blocks have this status and all of them are failed than failed status.
icon string icon of scene
  • Note: The scene could previously be created as not valid when loading a non-valid or non-matching event item type and the expression types contained inside, or it could be changed to non-valid values/types in the expression, this led to the fact that the scene data became invalid when subsequently loaded from the database and did not succumb change/delete and, accordingly, were in an unmanaged state in the database, since advanced_scenes/1.33 this behavior has been fixed. When creating, loading, or editing scenes containing expressions in events, the following is checked: the existence of items and expressions, the correctness of item values and expressions, and the matching of item types with expressions. In the case of loading a scene with incorrect events from the database, a scene with empty events and actions is created, which can later be modified or deleted. In case of creation or incorrect scene, an error will be returned.
Edit
Broadcasts Description
hub.scene.added Broadcast when the scene is successfully created.
hub.scene.run.progress Notification about the scene status. It’s fired when status of scene is changed.
Edit
Code Message Data
-32600 Bad request,
-32600 Bad request,
-32500 Scene is ill formed. Can’t parse when block
-32500 Scene is ill formed. Can’t parse then block
-32500 Scene is failed. There is no such method
-32500 Scene contain conditions for not intersect numbers values inside of AND condition
-32500 Scene contain conditions for same functionality inside of AND condition
-32500 Scene contain conditions for same functionality inside of AND condition
-32500 Scene cannot contain “isInterval” conditions along with other time based condition in the same AND operator
-32500 Failed to acquire anonymous plugin!
-32500 Expression error
-32500 Item does not exist
-32500 Item value type error
-32500 Expression does not exist
-32500 Scene has duplicate identifiers
  • Updated in : allowed creating scenes with multiple time conditions in the same AND operator. This applies to , , . But it is still forbidden to use conditions with other time-based conditions in the same AND operator.
Edit
  • Empty result or an error.
Edit
Edit
Edit
				
					{
    "id": "_ID_",
    "jsonrpc": "2.0",
    "method": "hub.scenes.create",
    "params": {
        "enabled": true,
        "group_id": null,
        "is_group": false,
        "name": "testRule",
        "parent_id": "5c6ec961cc01eb07f86f9dd9",
        "user_notifications" : [
            "324234234",
            "456456453", 
            "678678678"
        ],
        "house_modes" : [
            "1",
            "2", 
            "4"
        ],
        "then" : [
            {
                "blockOptions":{
                    "method":{
                        "args":{
                            "item":"item",
                            "value":"value"
                        },
                        "name":"setItemValue"
                    }
                },
                "blockType":"then",
                "fields":[
                    {
                        "name":"item",
                        "type":"item",
                        "value" : "897607_32771_1"
                    },
                    {
                        "name":"value",
                        "type":"int",
                        "value": 10
                    }
                ]
            }
        ],
        "when": [
            {
                "blockOptions": {
                    "method": {
                        "args": {
                            "item": "item",
                            "value": "value"
                        },
                        "name": "isItemState"
                    }
                },
                "blockType": "when",
                "fields": [
                    {
                        "name": "item",
                        "type": "item",
                        "value": "5c7fea6b7f00000ab55f2e55"
                    },
                    {
                        "name": "value",
                        "type": "bool",
                        "value": true
                    }
                ]
            }
        ]
    }
}				
			
Edit
				
					{
    "error": null,
    "id": "_ID_",
    "result": {}
}				
			
Edit
This is another example of the creation scene:
Edit
				
					{
    "id": "_ID_",
    "jsonrpc": "2.0",
    "method": "hub.scenes.create",
    "params": {
        "enabled": true,
        "group_id": null,
        "is_group": false,
        "name": "testRule",
        "parent_id": "5c6ec961cc01eb07f86f9dd9",
        "house_modes" : [
            "1",
            "2", 
            "4"
        ],
        "then" : [
            {
                "blockOptions":{
                    "method":{
                        "args":{
                            "item":"item",
                            "value":"value"
                        },
                        "name":"setItemValue"
                    }
                },
                "blockType":"then",
                "fields":[
                    {
                        "name":"item",
                        "type":"item",
                        "value" : "897607_32771_1"
                    },
                    {
                        "name":"value",
                        "type":"int",
                        "value": 10
                    }
                ]
            }
        ],
        "when": [
            {
                "blockOptions": {
                    "method": {
                        "args": {
                            "interval": "interval"
                        },
                        "name": "isInterval"
                    }
                },
                "blockType": "when",
                "fields": [
                    {
                        "name": "interval",
                        "type": "interval",
                        "value": "10s"
                    }
                ]
            }
        ]
    }
}				
			
Edit
				
					{
    "error": null,
    "id": "_ID_",
    "result": {}
}