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...
When blocks
when
block currently supports one or several events (conditions) and these blocks are connected by OR logical operators by default.
when
block json representation:
Field | Type | Required | Description |
---|---|---|---|
blockOptions | JsonObject | + | Options of the block |
blockOptions.method | JsonObject | + | Json representation of the function for triggering |
blockOptions.method.args | JsonObject | + | Json object with the names of the fields that must be extracted from the fields list |
blockOptions.method.name | string | + | Descibes the event type. Possible values: see below |
blockType | string | - | Name of the block type. Should be set as "when" |
blockName | string | - | User name of block |
fields | JsonArray | + | Array of the triggers. There is used the same format as it is in the then block but item address, values etc |
fields[].type | Enum | + | Represents the Item Value Type |
fields[].value | Any Json Value | + | actual value corresponding the field name |
isItemState
This events arises when the
value
of item is equal to thevalue
is set in this when block. Optionally it checks device armed status by logical AND operator with isItemState condition.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.item | string | + | Argument declaration of item ID. The value should be in field block with nameitem . |
blockOptions.method.args.value | string | + | Argument declaration of item value. The value should be in field block with namevalue . |
blockOptions.method.args.armed | string | - | Argument declaration of armed state of device is corresponding to current item. The value should be in field block with namearmed . This adds optional condition checks device armed status and is connected with isItemState condition by logical AND operator. |
Example:
"when" : [{
"blockOptions":{
"method":{
"args":{
"item":"item",
"value":"value",
"armed":"armed"
},
"name":"isItemState"
}
},
"blockType":"when",
"fields":[
{
"name":"item",
"type":"item",
"value" : "35656_5656_56"
},
{
"name":"value",
"type":"int",
"value":0
},
{
"name":"armed",
"type":"bool",
"value":true
}
]
}]
isButtonState
This events arises when the
value.button_state
of button_state item is equal to thevalue
is set in this when block. The Button Actions describe the possible values of this item.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.item | string | + | Argument declaration of item ID. The value should be in field block with nameitem . |
blockOptions.method.args.value | string | + | Argument declaration of item button_state. The value should be in field block with namevalue . |
Example:
"when" : [{
"blockOptions":{
"method":{
"args":{
"item":"item",
"value":"value"
},
"name":"isButtonState"
}
},
"blockType":"when",
"fields":[
{
"name":"item",
"type":"item",
"value" : "5e0218ea7f00003636b60dc8"
},
{
"name":"value",
"type":"token",
"value":"released"
}
]
}]
compareNumbers
This event arises when the
value
of item is corresponded to condition is set in this block. For example, if thecomparator
is==
,value
is equal to50
and item value is50
then event arises. If condition is>50
then event arises only once when threshold was exceeded. For example, if item value is49
and after that item value becomes51
then event arises. When item value becomes52
the event doesn't arise. The event will arise again when threshold was exceeded again. Similar situation is for other comparators (>=
,<
,<=
).
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.item | string | + | Argument declaration of item ID. The value should be in field block with nameitem . |
blockOptions.method.args.value | string | + | Argument declaration of item value. The value should be in field block with namevalue . |
blockOptions.method.args.comparator | string | + | Argument declaration of comparator state. The value should be in field block with namecomparator . Possible comparators are == , != , > , >= , < , <= . |
Example:
"when" : [
{
"blockType":"when",
"blockOptions":{
"method":{
"name":"compareNumbers",
"args":{
"item":"item",
"comparator":"comparator",
"value":"value"
}
}
},
"fields":[
{
"name":"item",
"type":"item",
"value":"5de64f6a70c7be0541cc0853"
},
{
"name":"comparator",
"type":"string",
"value": ">"
},
{
"name":"value",
"type":"int",
"value": 51
}
]
},
{
"blockType":"when",
"blockOptions":{
"method":{
"name":"compareNumbers",
"args":{
"item":"item",
"comparator":"comparator",
"value":"value"
}
}
},
"fields":[
{
"name":"item",
"type":"item",
"value":"5de64f6a70c7be0541cc0854"
},
{
"name":"comparator",
"type":"string",
"value": "<="
},
{
"name":"value",
"type":"float",
"value": 51.55
}
]
}
]
isInterval
Periodically fires the list of actions
Example:
"when" : [{
"blockOptions":{
"method":{
"args":{
"interval":"interval"
},
"name":"isInterval"
}
},
"blockType":"when",
"fields":[
{
"name":"interval",
"type":"interval",
"value":"212s"
}
]
}]
isSunState
Fires the actions corresponding sunset/sunrise event.it's possible to set the special days of the week or days of the month. Also timeoffset could be used. For that field before/after must be set.
arguments:
Sunstate | Description |
---|---|
sunrise | The possible values: intime , before or after |
sunset | The possible values: intime , before or after |
Example:
"when" : [{
"blockOptions":{
"method":{
"args":{
"sunstate":"sunrise",
"time":"time"
},
"name":"isSunState"
}
},
"blockType":"when",
"fields":[
{
"name":"sunrise",
"type":"string",
"value":"before"
},
{
"name":"time",
"type":"hms_interval",
"value":"10:30"
}
]
}]
isDate
Triggering periodically when the particular time, day or month has come. Daily event arises in each time what is within time array. Weekly event arises in each weekday what is set within weekday array in time what is set within time array. Monthly event arises in each day what is set within day array in time what is set within time array. The Gregorian Calendar is used.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.type | string | + | Argument declaration of schedule type. The value should be in field block with nametype . The possible values are daily , weekly or monthly . Daily type requires presence of time array only. Weekly type requires presence of both time array and weekday array. Monthly type requires presence of both time array and day array. |
blockOptions.method.args.time | string | + | Argument declaration of time array. The value should be in field block with nametime . The time array contains strings. The time format is "hh:mm" in 24-hour clock format. Type 24_hours_time_array . See Item Value Type. |
blockOptions.method.args.weekdays | string | - | Argument declaration of weekday array. The value should be in field block with nameweekday . The weekday array contains integer numbers. The possible values are 1..7 range. Type int_array . See Item Value Type. |
blockOptions.method.args.days | string | - | Argument declaration of day array. The value should be in field block with nameday . The day array contains integer numbers. The possible values are 1..31 range. If day is set to 31 then event works in each month where 31st day is present. Type int_array . See Item Value Type. |
Examples:
"when" : [{
"blockOptions":{
"method":{
"args":{
"type":"type",
"time":"time"
},
"name":"isDate"
}
},
"blockType":"when",
"fields":[
{
"name": "type",
"type": "string",
"value": "daily"
},
{
"name": "time",
"type": "24_hours_time_array",
"value": [ "10:20", "12:40", "13:32" ]
}
]
}]
"when" : [{
"blockOptions":{
"method":{
"args":{
"type":"type",
"time":"time",
"weekdays":"weekdays"
},
"name":"isDate"
}
},
"blockType":"when",
"fields":[
{
"name": "type",
"type": "string",
"value": "weekly"
},
{
"name": "time",
"type": "24_hours_time_array",
"value": [ "10:20", "12:40", "13:32" ]
},
{
"name": "weekdays",
"type": "int_array",
"value": [ 1, 2, 7 ]
}
]
}]
"when" : [{
"blockOptions":{
"method":{
"args":{
"type": "type",
"time":"time",
"days":"days"
},
"name":"isDate"
}
},
"blockType":"when",
"fields":[
{
"name": "type",
"type": "string",
"value": "monthly"
},
{
"name": "time",
"type": "24_hours_time_array",
"value": [ "10:20", "12:40", "13:32" ]
},
{
"name": "days",
"type": "int_array",
"value": [ 1, 5, 12 ]
}
]
}]
isOnce
Triggering when the particular date has come. The specific time, day, month and year should be set. The Gregorian Calendar is used.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.time | string | + | Argument declaration of time. The value should be in field block with nametime . The time is string. The time format is "hh:mm" in 24-hour clock format. Represents 24 hours time type. |
blockOptions.method.args.day | string | - | Argument declaration of day. The value should be in field block with nameday . The day is integer number. The possible values are 1..31 range but should not be more than last day of month. Represents int type. |
blockOptions.method.args.month | string | + | Argument declaration of month. The value should be in field block with namemonth . The month is integer number. The possible values are 1..12. Represents int type. |
blockOptions.method.args.year | string | + | Argument declaration of year. The value should be in field block with nametime . The year is integer number. Represents int type. |
Examples:
"when" : [{
"blockOptions":{
"method":{
"args":{
"time": "time",
"day": "day",
"month": "month",
"year": "year"
},
"name":"isOnce"
}
},
"blockType":"when",
"fields":[
{
"name": "time",
"type": "24_hours_time",
"value": "10:20"
},
{
"name": "day",
"type": "int",
"value": 5
},
{
"name": "month",
"type": "int",
"value": 12
},
{
"name": "year",
"type": "int",
"value": 2019
},
]
}]
isUserLockOperation
Triggering when the particular user locks door lock by entering a pin code.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.item | string | + | Argument declaration of Item ID of user_lock_operation item. The name is item . The type is item . |
blockOptions.method.args.state | string | + | Argument declaration of State. The name is state . The type is token . The value is always set to lock . |
blockOptions.method.args.user | string | + | Argument declaration of User ID. This User ID is one of keys are contained in itemId item. The type is dictionaryId . The corresponding field contains optionItemValue what contains itemId item Id. |
Example:
{
"blockType":"when",
"blockOptions":{
"method":{
"name":"isUserLockOperation",
"args":{
"item":"item",
"state":"state",
"user":"user"
}
}
},
"fields":[
{
"name":"item",
"type":"item",
"value":"5e4a5fef7f0000707ff6e9b2"
},
{
"name":"state",
"type":"token",
"value":"lock"
},
{
"name":"user",
"type":"dictionaryId",
"optionItemValue": {
"itemId": "5e4a5fef7f0000707ff6e9bd"
},
"value":"3"
}
]
}
hasAtLeastOneDictionaryValue
This event arises every time when element is added or is updated in dictionary and value of this element is equal to value is set in this block. Dictionary could have several elements with same value.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.item | string | + | Argument declaration of item ID. The value should be in field block with nameitem . |
blockOptions.method.args.value | string | + | Argument declaration of dictionary value. The value should be in field block with namevalue . |
Example:
{
"blockId": "<ID>",
"blockType": "when",
"blockOptions": {
"method": {
"name": "hasAtLeastOneDictionaryValue",
"args": {
"item": "item",
"value": "value"
}
}
},
"fields": [
{
"name": "item",
"type": "item",
"value": "5e4a5fef7f0000707ff6e9bd"
},
{
"name": "value",
"type": "token",
"options": [
{
"value": "low_battery",
"label": {
"lang_tag": "ui7_low_battery",
"text": "has low battery"
}
},
{
"value": "not_detected",
"label": {
"lang_tag": "ui7_sensor_not_detected",
"text": "is not detected"
}
}
],
"value": "low_battery"
}
]
}
Logic operators
and
The AND logic operator is when block. This condition is
true
in case when all conditions in blocks array aretrue
also. The AND operation could contain a different when blocks except some restictions are described below. The AND operator could contain a nested logic operators.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.blocks | string | + | The argument declaration of blocks field. The name is "blocks". The type is "blocks". The blocks field could contain several when blocks. If all contained blocks are true then this block is also true otherwise it is false . |
restrictions:
hub.scenes.edit and hub.scenes.create commands should check conflicts in conditions and send error in answer if conflict was detected:
Type of conflict | Error message | Error data |
---|---|---|
Have more then one isItemState block for same item | Scene contain conditions for same functionality inside of AND condition | scenes.when.same_item_in_and |
Have more then one isButtonState block for same item | Scene contain conditions for same functionality inside of AND condition | scenes.when.same_button_in_and |
Have more then one compareNumbers block for same item and all of that have not intersect ranges | Scene contain conditions for not intersect numbers values inside of AND condition | scenes.when.not_intersect_numbers |
Have more then one Time condition block in AND block | Scene cannot contain more than one "time" condition in the same AND operator | scenes.when.more_than_one_time |
Examples:
{
"blockType":"when",
"blockOptions":{
"method":{
"name":"and",
"args":{
"blocks":"blocks"
}
}
},
"fields":[
{
"name":"blocks",
"type":"blocks",
"value": [
{
__WHEN_BLOCK__
},
{
__WHEN_BLOCK__
},
{
"blockType":"when",
"blockOptions":{
"method":{
"name":"and",
"args":{
"blocks":"blocks"
}
}
},
"fields":[
{
"name":"blocks",
"type":"blocks",
"value": [
{
__WHEN_BLOCK__
},
{
__WHEN_BLOCK__
}
]
}
]
}
]
}
]
}
not
The NOT logic operator is when block. This condition is
true
if contained condition isfalse
otherwise if contained condition istrue
then it isfalse
. The NOT operation could contain any when block. The NOT operator could contain a nested logic operator.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.block | string | + | The argument declaration of block field. The name is "block". The type is "block". The block field could contain when only one block. This condition is true if contained condition is false otherwise if contained condition is true then it is false . |
Examples:
{
"blockType":"when",
"blockOptions":{
"method":{
"name":"not",
"args":{
"block":"block"
}
}
},
"fields":[
{
"name":"block",
"type":"block",
"value": {
"blockType":"when",
"blockOptions":{
"method":{
"name":"not",
"args":{
"block":"block"
}
}
},
"fields":[
{
"name":"block",
"type":"block",
"value": {
__WHEN_BLOCK__
}
}
]
}
}
]
}
or
The OR logic operator is when block. This condition is
true
if any contained condition istrue
otherwise if all contained condition isfalse
then it is alsofalse
. The OR operation could contain several when blocks. The OR operator could contain a nested logic operators.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.blocks | string | + | The argument declaration of blocks field. The name is "blocks". The type is "blocks". The blocks field could contain several when blocks. If any contained block is true then this block is also true otherwise it is false . |
Examples:
{
"blockType":"when",
"blockOptions":{
"method":{
"name":"or",
"args":{
"blocks":"blocks"
}
}
},
"fields":[
{
"name":"blocks",
"type":"blocks",
"value": [
{
__WHEN_BLOCK__
},
{
__WHEN_BLOCK__
},
{
"blockType":"when",
"blockOptions":{
"method":{
"name":"or",
"args":{
"blocks":"blocks"
}
}
},
"fields":[
{
"name":"blocks",
"type":"blocks",
"value": [
{
__WHEN_BLOCK__
},
{
__WHEN_BLOCK__
}
]
}
]
}
]
}
]
}
Then blocks
then
block currently supports one or several actions and execution of these actions is provided in order is set in array ofthen
block.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions | JsonObject | + | Action block options |
blockOptions.method | JsonObject | + | Action description |
blockOptions.method.args | JsonObject | + | Action description arguments that should be read from field attribute |
blockOptions.method.name | string | + | Name of action |
fields | JsonArray | + | Array of fields that must be extracted by the blockOptions.method.args names |
fields[].name | string | + | Name of the field block corresponding of the declaration in blockOptions.method.args |
fields[].type | string | - | Represents the Item Value Type |
fields[].value | string | + | Value should be corresponded to the fields[].type |
delay | JsonObject | - | Delay to action after event arises. If this field is absent or is empty then delay is absent. |
delay.seconds | int | - | Seconds number of delay |
delay.minutes | int | - | Minutes number of delay |
delay.hours | int | - | Hours number of delay |
delay.days | int | - | Days number of delay |
exec_policy | string | - | It is execution policy of block. The block policy have higher priority then policy of scene ( see description of hub.scenes.create ). If block policy is absent then block inherits policy of scene. 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. |
setItemValue
Set the value for the specific item.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.item | string | + | Argument declaration of of Item ID. The name is item . The type is item . |
blockOptions.method.args.value | string | + | Argument declaration of Value should be set to item when event arises. The name is value . The type is value . |
Examples:
"then" : [{
"blockOptions":{
"method":{
"args":{
"item":"item",
"value":"value"
},
"name":"setItemValue"
}
},
"blockType":"then",
"delay" : {
"seconds": 12,
"minutes": 30,
"hours": 1,
"days": 0
},
"fields":[
{
"name":"item",
"type":"item",
"value" : "897607_32771_1"
},
{
"name":"value",
"type":"int",
"value": 10
}
]
}]
Examples of possible values:
{
"name":"value",
"type":"bool",
"value": false
}
{
"name":"value",
"type":"token",
"value": "idle_off"
}
{
"name":"value",
"type":"power",
"value": 30,
"scale": "watt"
}
{
"name":"value",
"type": "float",
"value": 5.0
}
{
"name":"value",
"type": "string",
"value": "example"
}
setDeviceArmed
Set device flag Armed.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.device | string | + | Argument declaration of Device ID. The name is device . The type is device . |
blockOptions.method.args.deviceFlag | string | + | Argument declaration of Device Flag can have boolean type only. The name is deviceFlag . The type is bool . |
Example:
"then" : [{
"blockOptions": {
"method":{
"args":{
"device":"device",
"deviceFlag":"deviceFlag"
},
"name":"setDeviceArmed"
}
},
"blockType":"then",
"fields":[
{
"name":"device",
"type":"device",
"value" : "76asdasd76yasf89"
},
{
"name":"deviceFlag",
"type":"bool",
"value" : false
}
]
}]
sendCloudAbstractCommand
Send cloud.controller_abstracts_set request to Cloud. Controller should convert execution of this block to request and send it to Cloud. Scene is blocked until answer would be received. If answer was received and it has error field with null value then next then-block should be processed. If no answers in 1 minute or answer has error then scene should be failed and stopped. If controller doesn't have connection with cloud then scene should be failed.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.abstractId | string | + | Argument declaration of Abstract ID of command. The name is abstract . The type is string . |
blockOptions.method.args.capability | string | + | Argument declaration of Capability. The name is capability . The type is string . |
blockOptions.method.args.command | string | + | Argument declaration of Command . The name is command . The type is string . |
blockOptions.method.args.parameters | string | + | Argument declaration of Parameters. The name is parameters . The type is object . |
Example:
{
"blockOptions":{
"method":{
"name":"sendCloudAbstractCommand",
"args":{
"abstractId":"abstract",
"capability":"capability",
"command":"command",
"parameters":"parameters"
}
}
},
"blockType":"then",
"fields":[
{
"name":"abstract",
"type":"string",
"value": "asdasdn-2342342-23423"
},
{
"name":"capability",
"type":"string",
"value": "text_command"
},
{
"name":"command",
"type":"string",
"value": "send"
},
{
"name":"parameters",
"type":"object",
"value": {
"text": "turn on the light"
}
}
]
}
Example of Cloud request:
{
"id": "5c6ec961cc01eb07f86f9dd9",
"method": "cloud.controller_abstracts_set",
"api": "1.0",
"params": {
"uuid": "asdasdn-2342342-23423",
"capability": "text_command",
"command": "send",
"parameters": {
"text": "turn on the light"
}
}
}
switchHouseMode
Change house mode.
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.houseMode | string | + | Argument declaration of House Mode. The name is houseMode . The type is houseModeId . |
Errors:
Internal error code | Message | Data |
---|---|---|
HOUSE_MODE_DOES_NOT_EXIST | The house mode with this id does not exist | ezlo.house_mode.not.exist |
BAD_PARAMS | Wrong params, | rpc.params.invalid. |
Example:
"then" : [{
"blockOptions":{
"method":{
"name":"switchHouseMode",
"args":{
"houseMode":"houseMode"
}
}
},
"blockType":"then",
"fields":[
{
"name":"houseMode",
"type":"houseModeId",
"value": "2"
}
]
}]
sendHttpRequest
Send HTTP request
parameters:
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.url | string |
+ | Target url. It can contain port. |
blockOptions.method.args.credential | credential | - | User and password for HTTP authorization. |
blockOptions.method.args.request | string | - | Type of request. Possible value: GET, POST, PUT, DELETE. Default value: GET. |
blockOptions.method.args.contentType | string | - | Type of sending content |
blockOptions.method.args.content | string | - | Sending content |
blockOptions.method.args.headers | dictionary | - | Set of custom HTTP headers |
blockOptions.method.args.skipSecurity | bool | - | Skip any security checks: check date, domain, and self-signed certificates criteria. Default value: false. |
Example:
{
"blockOptions":{
"method":{
"name":"sendHttpRequest",
"args":{
"url":"url",
"credential":"credential",
"request":"request",
"contentType":"contentType",
"content":"content",
"headers":"headers",
"skipSecurity":"skipSecurity"
}
}
},
"blockType":"then",
"fields":[
{
"name":"url",
"type":"string",
"value": "https://ezlo.com/"
},
{
"name":"credential",
"type":"credential",
"value": {
"user":"admin",
"password":"admin"
}
},
{
"name":"request",
"type":"string",
"value": "POST"
},
{
"name":"contentType",
"type":"string",
"value": "text/plain"
},
{
"name":"content",
"type":"string",
"value": "Request check"
},
{
"name":"headers",
"type":"dictionary",
"value": {
"token":"SecurityToken13"
}
},
{
"name":"skipSecurity",
"type":"bool",
"value": false
}
]
}
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 |
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 |
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 correspondely |
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
}
}