setExpression
- Set new parameters for an existing expression.
- This feature is available since advanced_scenes/1.36 version
Edit
Field | Type | Required | Description |
---|---|---|---|
blockOptions.method.args.name | string | + | Name for an expression. Max 30 characters. |
blockOptions.method.args.code | string | – | Lua code snippet to be run within a scene (Max 5 kb) |
blockOptions.method.args.valueType | string | – | A type of value returned by an expression. Required for expressions used by the Scenes Engine. If set, the Lua code should return only values, from which the variable of a given value type can be constructed. |
blockOptions.method.args.metadata | object | – | Any metadata bound to an expression. Can be of any JSON type. If null, should not be stored. |
blockOptions.method.args.params | object | – | Expression parameters |
Edit
Data | Internal error code | Message |
---|---|---|
rpc.params.invalid.{FIELD} | BAD_PARAMS | Wrong params, |
Edit
Edit
Case 1: set new code/valueType fields:
Request
{
"blockOptions": {
"method": {
"name": "setExpression",
"args": {
"name": "name",
"valueType": "valueType",
"metadata": "metadata",
"code": "code"
},
}
},
"blockType": "then",
"fields": [
{
"name": "name",
"type": "string",
"value": "expression.name"
},
{
"name": "code",
"type": "string",
"value": "return (some Lua code calculations here)"
},
{
"name": "valueType",
"type": "string",
"value": "int"
},
{
"name": "metadata",
"type": "object",
"value": {"key":"value"}
}
]
}
Edit
Case2: set new code/valueType/params properties of an expression:
Request
{
"blockOptions": {
"method": {
"args": {
"name": "name",
"type": "type",
"code": "code",
"valueType": "valueType",
"params": "params"
},
"name": "setExpression"
}
},
"blockType": "then",
"fields": [
{
"name": "name",
"type": "string",
"value": "expression.name"
},
{
"name": "type",
"type": "string",
"value": "code"
},
{
"name": "code",
"type": "string",
"value": "return (some Lua code calculations here)"
},
{
"name": "valueType",
"type": "string",
"value": "valueTypeEnum"
},
{
"name": "params",
"type": "object",
"value": {
"items": [
{
"name": "kitchenTemperatureSetpoint",
"_id": "5fecdf73222aaa175f6d6be4"
},
{
"name": "hallTemperatureSetpoint",
"_id": "60c7696b933ffb710a8be319"
}
]
}
}
]
}