Scenes General information

Scenes provide the possibility to make the relations between devices and make some actions with them. Generally they are named as conditions and actions so this 2 blocks are: when and then. Both have Json Array representation. In the perfect case when (conditions) block must forming AST from the Json (Abstract Syntaxis Tree) and be executable. Currently it represents as the list of possible single-argument function.
then (action) block contains the list of actions. Each functional element actually is the item. As far as you can see there are read only items such as : temperature, pressure, humidity etc.. and there are read-write items : switch, dimmer, light(switch), doorlock etc...

Scenes commands

hub.scenes.create

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Create a new scene.

parameters:

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.
parent_id string - room identifier for that it was created. If parent_id is not set then it should have empty value for both hub.scenes.list and hub.scenes.get
then JsonArray + Array of the actions blocks
when JsonArray + Array of the conditions blocks
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 when block and this condition is connected with when block by logical AND operator. So if one of conditions arises and one of these house modes is set then actions 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: check_result - result of execution each block should checked and scene should be failed in case if block is failed; ignore_result - 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

broadcasts:

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.

errors:

Code Message Data
-32600 Bad request, rpc.params.empty.{FIELD}
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 Scene is ill formed. Can't parse when block ezlo.scenes.block.when.wrong
-32500 Scene is ill formed. Can't parse then block ezlo.scenes.block.then.wrong
-32500 Scene is failed. There is no such method ezlo.scenes.method.unknown
-32500 Scene contain conditions for not intersect numbers values inside of AND condition scenes.when.not_intersect_numbers
-32500 Scene contain conditions for same functionality inside of AND condition scenes.when.same_button_in_and
-32500 Scene contain conditions for same functionality inside of AND condition scenes.when.same_item_in_and
-32500 Scene cannot contain more than one "time" condition in the same AND operator scenes.when.more_than_one_time
-32500 Failed to acquire anonymous plugin! anonymous.plugin.acquire.failed

return result fields:

Empty result or an error.

Here is it an example of usage:

call:

{
    "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
                    }
                ]
            }
        ]
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

This is another example of the creation interval scene:

{
    "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"
                    }
                ]
            }
        ]
    }
}
{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.scenes.get

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Get scene json object.

parameters:

Field Type Required Description
_id string + rule identifier

return result fields:

Return the json object of the rule. See hub.scenes.create.

errors:

Code Message Data
-32600 Bad request, rpc.params.empty.{FIELD}
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 The scene with this id does not exist ezlo.scenes.not.exist

Here is it an example of usage:

call:

{
    "id": "_ID_",
    "jsonrpc": "2.0",
    "method": "hub.scenes.get",
    "params": {
        "_id": "5c7ff48b7f00002a07a408e3"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
        "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"
                    }
                ]
            }
        ]
    }
}

hub.scenes.list

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Get scene json object.

parameters:

No parameters required.

return result fields:

The array of the rule objects which are described at hub.scenes.create

Here is it an example of usage:

call:

{
    "id": "_ID_",
    "jsonrpc": "2.0",
    "method": "hub.scenes.list",
    "params": {}
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
         "scenes":
        [
        {
            "_id": "5c7ff48b7f00002a07a408e3",
            "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": {
                                "item": "item",
                                "value": "value"
                            },
                            "name": "isItemState"
                        }
                    },
                    "blockType": "when",
                    "fields": [
                        {
                            "name": "item",
                            "type": "item",
                            "value": "5c7fea6b7f00000ab55f2e55",
                        },
                        {
                            "name": "value",
                            "type": "bool",
                            "value": true
                        }
                    ]
                }
            ]
        }
    ]
  }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.scenes.edit

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Update the scene json by it's id.

parameters:

Field Type Required Description
_id string + rule identifier
eo JsonObject + Json object of the rule description. Please see hub.scenes.create

broadcasts:

Broadcasts Description
hub.scene.changed Updating the information about the scene.

return result fields:

Empty result or an error

errors:

Code Message Data
-32600 Bad request, rpc.params.empty.{FIELD}
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 Scene is ill formed. Can't parse when block ezlo.scenes.block.when.wrong
-32500 Scene is ill formed. Can't parse then block ezlo.scenes.block.then.wrong
-32500 Scene is failed. There is no such method ezlo.scenes.method.unknown
-32500 Scene contain conditions for not intersect numbers values inside of AND condition scenes.when.not_intersect_numbers
-32500 Scene contain conditions for same functionality inside of AND condition scenes.when.same_button_in_and
-32500 Scene contain conditions for same functionality inside of AND condition scenes.when.same_item_in_and
-32500 Scene cannot contain more than one "time" condition in the same AND operator scenes.when.more_than_one_time
-32500 Failed to acquire anonymous plugin! anonymous.plugin.acquire.failed

Here is an example of usage:

call:

{
    "id": "_ID_",
    "jsonrpc": "2.0",
    "method": "hub.scenes.edit",
    "params" :
     {
         "_id": "5c5318aa518af44041018347",
         "eo": {
             "_id": "5c5318aa518af44041018347",
             "enabled": true,
             "group_id": null,
             "is_group": false,
             "name": "NewR",
             "parent_id": "5c050abd518af4117b2e2496",
             "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
                          }
                      ]
                  },
                 {
                     "blockOptions": {
                         "method": {
                             "args": {
                                 "item": "item"
                             },
                             "name": "decreaseDimmer"
                         }
                     },
                     "blockType": "then",
                     "fields": [
                         {
                             "name": "item",
                             "type": "item",
                             "value": "897607_32771_1"                                                              
                         }
                     ]
                 }
             ],
             "when": [
                 {
                     "blockOptions": {                                                           
                         "method": {
                             "args": {
                                 "item": "item",
                                 "value": "value"
                             },
                             "name": "isItemState"
                         }
                     },
                     "blockType": "when",
                     "fields": [
                         {                                                               
                             "name": "item",
                             "type": "item",
                             "value": "897607_32770_1"                                                            
                         },
                         {
                             "name": "value",
                             "type": "bool",
                             "value": true
                         }
                     ]
                 }
             ]
         },
         "permission": {
             "devices": "s",
             "ezlo": "s",
             "rules": "s",
             "ui": "s",
             "users": "s"
         },
         "sender": "_USER_",
         "serial": "_HUB_ID_"
     }
}

hub.scenes.delete

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Delete the scene by it's id.

parameters:

Field Type Required Description
_id string + scene identifier

broadcasts:

Broadcasts Description
hub.scene.deleted Notification about the scene deleting.

return result fields:

Empty result or an error.

errors:

Code Message Data
-32600 Bad request, rpc.params.empty.{FIELD}
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 The scene with this id does not exist ezlo.scenes.not.exist

Here is it an example of usage:

{
    "id": "_ID_",
    "jsonrpc": "2.0",
    "method": "hub.scenes.delete",
    "params": {
        "_id": "5c7ff48b7f00002a07a408e3"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.scenes.blocks.list

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Getting possible conditional/action blocks related to the current device set on the hub for creating the scenes.

parameters:

Field Type Required Description
blockType string + enumed literal value. Possible values :
devices stringArray + The array of device IDs are used for filtering of items by device ID

return result fields: they are depend on the input param

Field Type Required Description
when JsonArray + Array of the possible WHEN blocks related to the current devices/items which are included. By them full set of rules is filtered

or

Field Type Required Description
then JsonArray + Array of the possible THEN blocks related to the current devices/items which are included. By them full set of rules is filtered

Here is it an example of usage:

{
    "id": "_ID_",
    "jsonrpc": "2.0",
    "method": "hub.scenes.blocks.list",
    "params": {
        "blockType": "when",
        "devices": [ "5dd2a8eebfb5be6d20008c55" ]
    }
}

reply:

 {
    "error": null,
    "id": "_ID_",
    "result": {
        "when": [
            {
                "label": {
                    "lang_tag": "ui0_token",
                    "text": "English string"
                },
                "blockOptions":{
                    "method":{
                        "args":{
                            "item":"item",
                            "value":"value",
                            "armed": "armed"
                        },
                        "name":"isItemValue"
                    }
                },
                "blockType":"when",
                "fields":[
                    {
                        "name":"item",
                        "type":"item",
                        "value" : "5dd2a8efc1b5be6d20008c56"
                    },
                    {
                        "name":"value",
                        "type":"bool",
                        "options":[
                            {
                                "value":true,
                                "label": {
                                    "lang_tag": "ui1_token",
                                    "text": "Enable"
                                }
                            },
                            {
                                "value":false,
                                "label": {
                                    "lang_tag": "ui2_token",
                                    "text": "Disable"
                                }
                            }
                        ],
                        "value": true
                    },
                    {
                        "name":"armed",
                        "type":"bool",
                        "value":true
                    }
                ]
            },
            {
                "label":{
                    "lang_tag":"ui0_token",
                    "text":"English string"
                },
                "blockOptions": {
                    "method": {
                        "args": {
                            "item": "item",
                            "comparator":"comparator",
                            "value":"value"
                        },
                        "name": "compareNumbers"
                    }
                },
                "blockType": "when",
                "fields": [
                    {
                        "name": "item",
                        "type": "item",
                        "value": "897607_32771_2"
                    },
                    {
                        "name":"comparator",
                        "type":"string",
                        "options":[
                            {
                                "value":"==",
                                "label":{
                                    "lang_tag":"ui3_token",
                                    "text":"Equal"
                                }
                            },
                            {
                                "value":"!=",
                                "label":{
                                    "lang_tag":"ui4_token",
                                    "text":"Not equal"
                                }
                            },
                            {
                                "value":">",
                                "label":{
                                    "lang_tag":"ui5_token",
                                    "text":"Greater"
                                }
                            },
                            {
                                "value":"<",
                                "label":{
                                    "lang_tag":"ui6_token",
                                    "text":"Less"
                                }
                            },
                            {
                                "value":">=",
                                "label":{
                                    "lang_tag":"ui7_token",
                                    "text":"Greater and equal"
                                }
                            },
                            {
                                "value":"<=",
                                "label":{
                                    "lang_tag":"ui8_token",
                                    "text": "Less and equal"
                                }
                            }
                        ],
                        "value":"=="
                    },
                    {
                        "name":"value",
                        "type":"int",
                        "value": 10
                    }
                ]
            },
            {
                "label": {
                    "lang_tag": "ui0_token",
                    "text": "English string"
                },
                "blockOptions": {
                    "method": {
                        "args": {
                            "item": "item",
                            "value":"value"
                        },
                        "name": "isDictonaryValueState"
                    }
                },
                "blockType": "when",
                "fields": [
                    {
                        "name": "item",
                        "type": "item",
                        "value": "897607_32771_3"
                    },
                    {
                        "name":"value",
                        "type":"token",
                        "options":[
                            {
                                "value":"low_battery",
                                "label": {
                                    "lang_tag": "ui9_token",
                                    "text": "Low battery"
                                }
                            },
                            {
                                "value":"not_detected",
                                "label": {
                                    "lang_tag": "ui10_token",
                                    "text": "Not detected"
                                }
                            }
                        ],
                        "value": "low_battery"
                    }
                ]
            }
        ]
    }
}

hub.scenes.enabled.set

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Gives the possibility to enable or disable scene.

parameters:

Field Type Required Description
_id string + scene identifier
enabled boolean + setting for enabling/disabling state correspondingly

broadcasts:

Broadcasts Description
hub.scene.changed Updating the information about the scene.

return result fields:

Empty result or an error.

errors:

Code Message Data
-32600 Bad request, rpc.params.empty.{FIELD}
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 The scene with this id does not exist ezlo.scenes.not.exist

Here is it an example of usage:

{
    "id": "_ID_",
    "jsonrpc": "2.0",
    "method": "hub.scenes.enabled.set",
    "params": {
        "_id": "_SCENE_ID_",
        "enabled" : false
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.scenes.notification.add

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Add user ID to particular scene for sending notification broadcasts.

parameters:

Field Type Required Description
sceneId string + Id of the scene
userId string + Id of the user

broadcasts:

Broadcasts Description
hub.scene.changed Updating the information about the scene.

errors:

Code Message Data
-32600 Bad request, rpc.params.empty.{FIELD}
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 The scene with this id does not exist ezlo.scenes.not.exist

Here is it an example of usage:

call:

{
    "method": "hub.scenes.notification.add",
    "id": "_ID_",
    "params": {
        "sceneId": "d233cdel43422",
        "userId": "3232323215533"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.scenes.notification.remove

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Remove user ID from particular scene. Notification broadcasts won't be sent to this user.

parameters:

Field Type Required Description
sceneId string + Id of the scene
userId string + Id of the user

broadcasts:

Broadcasts Description
hub.scene.changed Updating the information about the scene.

errors:

Code Message Data
-32600 Bad request, rpc.params.empty.{FIELD}
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 The scene with this id does not exist ezlo.scenes.not.exist

Here is it an example of usage:

call:

{
    "method": "hub.scenes.notification.remove",
    "id": "_ID_",
    "params": {
        "sceneId": "d233cdel43422",
        "userId": "3232323215533"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.scenes.run

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Run particular scene manually.

parameters:

Field Type Required Description
sceneId string + Id of the scene

broadcasts:

Broadcasts Description
hub.scene.run.progress Notification about the scene status. It's fired when status of scene is changed.

errors:

Code Message Data
-32600 Bad request, rpc.params.empty.{FIELD}
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 The scene with this id does not exist ezlo.scenes.not.exist

Here is it an example of usage:

call:

{
    "method": "hub.scenes.run",
    "id": "_ID_",
    "params": {
        "sceneId": "d233cdel43422"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.scenes.room.set

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Link a scene with a particular room.

parameters:

Field Type Required Description
sceneId string + Id of the scene
roomId string + Id of the room

broadcasts:

Broadcasts Description
hub.scene.changed Updating the information about the scene

errors:

Code Message Data
-32600 Bad request, rpc.params.empty.{FIELD}
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 The scene with this id does not exist ezlo.scenes.not.exist

Here is it an example of usage:

call:

{
    "method": "hub.scenes.room.set",
    "id": "_ID_",
    "params": {
        "sceneId": "d233cdel43422",
        "roomId": "23423dfsd2323"
    }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {}
}

hub.scenes.time.list

Version: 1.0

Classes: UI

Title: Time scenes list

Description: All scenes have time condition in "when" block are present in this list . Returns list of time scenes in chronological order ( first run scene on top of list ).

parameters:

No parameters required.

return result fields:

The "timeScenes" array of the objects which are described in table:

Field Type Required Description
sceneId string + Id of the scene
sceneName string + Name of the scene
methodName string + Name of the method
executionDate string + Nearest date of the scene execution in format (ISO 8601: "YYYY-MM-DDThh:mm:ss±hhmm")

Here is it an example of usage:

call:

{
    "id": "_ID_",
    "jsonrpc": "2.0",
    "method": "hub.scenes.time.list",
    "params": {}
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
        "timeScenes": [
            {
                "sceneId": "kgRFEa7CL8ukevX3",
                "sceneName": "Every hour",
                "methodName": "isInterval",
                "executionDate": "2019-04-06T18:20:00+0200"
            },
            {
                "sceneId": "d233cdel43422",
                "sceneName": "Every Morning",
                "methodName": "isSunState",
                "executionDate": "2019-05-06T06:20:00+0200"
            },
            {
                "sceneId": "gnoVvx4ApUHzHAPa",
                "sceneName": "50 anniversary",
                "methodName": "isOnce",
                "executionDate": "2019-05-07T12:40:00+0200"
            },
            {
                "sceneId": "sHNQTjMaXeAUUFRd",
                "sceneName": "Daily schedule",
                "methodName": "isDate",
                "executionDate": "2019-05-08T10:00:00+0200"
            }
        ]
    }
}

hub.scenes.trigger.devices.list

Version: 1.0

Classes: UI

Title: The list of trigger devices

Description: The list of trigger devices. The items of these devices could be used as trigger for scene. The possible condition blocks could be received by request hub.scenes.blocks.list.

parameters:

No parameters required.

return result fields:

The "timeScenes" array of the objects which are described in table:

Field Type Required Description
devices StringArray + The array of trigger device Ids

Here is it an example of usage:

call:

{
    "id": "_ID_",
    "jsonrpc": "2.0",
    "method": "hub.scenes.trigger.devices.list",
    "params": {}
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
        "devices": [ "5e00eff62fcabe6fb9995099", "5dde952d10eabe175a17d7af" ]
    }
}

hub.scenes.icon.set

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Set icon of scene ( icon field in root scope of scene fields )

parameters:

Field Type Required Description
_id string + id of the scene
icon string + icon of scene

return result fields:

Empty result.

errors:

Code Message Data
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 The scene with this id does not exist ezlo.scenes.not.exist
-32602 Value is not in valid range rpc.params.range.invalid.{FIELD}

Here is it an example of usage:

call:

{
     "id": "ID",
     "jsonrpc": "2.0",
     "method": "hub.scenes.icon.set",
     "params": {
         "_id": "_SCENE_ID_",
         "icon" : "icon3"
     }
 }

reply:

{
     "error": null,
     "id": "ID",
     "result": {}
}

hub.scenes.name.set

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Set name of scene ( name field in root scope of scene fields )

parameters:

Field Type Required Description
_id string + id of the scene
name string + name of scene

return result fields:

Empty result.

errors:

Code Message Data
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 The scene with this id does not exist ezlo.scenes.not.exist
-32602 Value is not in valid range rpc.params.range.invalid.{FIELD}

Here is it an example of usage:

call:

{
     "id": "ID",
     "jsonrpc": "2.0",
     "method": "hub.scenes.name.set",
     "params": {
         "_id": "_SCENE_ID_",
         "name" : "New name"
     }
 }

reply:

{
     "error": null,
     "id": "ID",
     "result": {}
}

hub.scenes.house_modes.set

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Set house modes of scene ( house_modes field in root scope of scene fields )

parameters:

Field Type Required Description
_id string + id of the scene
houseModes JsonArray + house modes of scene

return result fields:

Empty result.

errors:

Code Message Data
-32600 Bad request, rpc.params.notfound.{FIELD}
-32500 The scene with this id does not exist ezlo.scenes.not.exist
-32602 Value is not in valid range rpc.params.range.invalid.{FIELD}

Here is it an example of usage:

call:

{
     "id": "ID",
     "jsonrpc": "2.0",
     "method": "hub.scenes.house_modes.set",
     "params": {
         "_id": "_SCENE_ID_",
         "houseModes" : [
                "1",
                "2",
                "4"
            ]
     }
 }

reply:

{
     "error": null,
     "id": "ID",
     "result": {}
}

hub.scenes.action.block.test

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Test action block workability

parameters:

Field Type Required Description
block JsonObject + action block for scene

return result fields:

Field Type Required Description
httpAnswerCode int - response code of http request

errors:

Code Message Data
-32600 Bad request, rpc.params.empty.{FIELD}
-32600 Wrong params, rpc.params.invalid.{FIELD}
-32500 Scene is ill formed. Can't parse then block ezlo.scenes.block.then.wrong
-32500 Scene is failed. There is no such method ezlo.scenes.method.unknown

Here is it an example of usage:

call:

{
   "id":"_ID_",
   "jsonrpc":"2.0",
   "method":"hub.scenes.action.block.test",
   "params":{
      "block":{
         "blockOptions":{
            "method":{
               "name":"sendHttpRequest",
               "args":{
                  "url":"url",
                  "request":"request"
               }
            }
         },
         "blockType":"then",
         "fields":[
            {
               "name":"url",
               "type":"string",
               "value":"https://ezlo.com/"
            },
            {
               "name":"request",
               "type":"string",
               "value":"POST"
            }
         ]
      }
   }
}

reply:

{
     "error": null,
     "id": "ID",
     "result": {
         "httpAnswerCode":200
     }
}

Scenes script related commands

Look at anonymous plugin and runCustomScript.

hub.scenes.scripts.add

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Add/load a new script snippet for using in scenes

parameters:

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 )

return result fields:

Field Type Required Description
_id string + Unique id of an added/loaded script snippet

errors:

Code Message Data
-32600 Wrong params, rpc.params.invalid.{FIELD}

Here is it an example of usage:

call:

{
   "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"
   }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
        "_id": "5cf0dc8c7f000068d223e88a"
    }
}

hub.scenes.scripts.set

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Change a script snippet, you can modify a script snippet even if the script snippet is associated with some scene.

parameters:

Field Type Required Description
_id string + Id of a script snippet to change
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 )

errors:

Code Message Data
-32600 Wrong params, rpc.params.invalid.{FIELD}
-32600 Anonymous plugin doesn't exist! anonymous.plugin.doesnot.exist

Here is it an example of usage:

call:

{
   "id":"_ID_",
   "jsonrpc":"2.0",
   "method":"hub.scenes.scripts.set",
   "params":{
      "_id": "5cf0dc8c7f000068d223e88a",
      "name": "better name than was before"
   }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
    }
}

hub.scenes.scripts.get

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Get content of a script snippet

parameters:

Field Type Required Description
_id string + Id of a script snippet to get

return result fields:

Field Type Required Description
_id string + Id of a script snippet
code string + Lua code snippet
name string - Title for the script snippet

errors:

Code Message Data
-32600 Wrong params, rpc.params.invalid.{FIELD}
-32600 Anonymous plugin doesn't exist! anonymous.plugin.doesnot.exist

Here is it an example of usage:

call:

{
   "id":"_ID_",
   "jsonrpc":"2.0",
   "method":"hub.scenes.scripts.get",
   "params":{
      "_id":"5cf0dc8c7f000068d223e88a"
   }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
        "_id": "5cf0dc8c7f000068d223e88a",
        "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"
    }
}

hub.scenes.scripts.delete

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Delete a script snippet, a script snippet can be removed only if it's not referenced by any scene action block (or it's not associated with any scene). Script snippet gets removed automatically if it has been associated with one or several scenes and if last scene owning this script snippet was removed.

Note: Script snippet can be unreferenced either by removing or by editing a scene that previously had an association with this script snippet.

parameters:

Field Type Required Description
_id string + Id of a script snippet to delete

errors:

Code Message Data
-32600 Wrong params, rpc.params.invalid.{FIELD}
-32500 Anonymous plugin acquired! anonymous.plugin.acquired
-32600 Anonymous plugin doesn't exist! anonymous.plugin.doesnot.exist

Here is it an example of usage:

call:

{
   "id":"_ID_",
   "jsonrpc":"2.0",
   "method":"hub.scenes.scripts.delete",
   "params":{
      "_id":"5cf0dc8c7f000068d223e88a"
   }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
    }
}

hub.scenes.scripts.list

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: List all added/loaded script snippets

return result fields:

Field Type Required Description
_id string + Id of a script snippet
name string - Title for the script snippet

Here is it an example of usage:

call:

{
   "id":"_ID_",
   "jsonrpc":"2.0",
   "method":"hub.scenes.scripts.list",
   "params":{}
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
        "scripts":[ {
            "_id": "5cf0dc8c7f000068d223e88a",
            "name":"Switch on all lights"
          },
          {
            "_id": "5aa0dc8c7f000068d223e88a",
            "name":"Switch off all lights"
          }
        ]
    }
}

hub.scenes.scripts.run

Version: 1.0

Classes: UI

Title: Scene manager categories

Description: Run a script snippet

parameters:

Field Type Required Description
_id string + Id of a script snippet to run

errors:

Code Message Data
-32600 Wrong params, rpc.params.invalid.{FIELD}
-32600 Anonymous plugin doesn't exist! anonymous.plugin.doesnot.exist
-32500 Script error ezlo.lua.script.error

Here is it an example of usage:

call:

{
   "id":"_ID_",
   "jsonrpc":"2.0",
   "method":"hub.scenes.scripts.run",
   "params":{
      "_id":"5cf0dc8c7f000068d223e88a"
   }
}

reply:

{
    "error": null,
    "id": "_ID_",
    "result": {
    }
}