2022-10-04T10:04:30+0200 \u003cwarn\u003e scene.executeActions.js:37 (executeAction) Error: Parse error on line 2:
...": {{1.0.data.result}}}
-----------------------^
Expecting 'CLOSE', 'OPEN_SEXPR', 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'CLOSE_UNESCAPED'
at Parser.parseError (/src/server/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:267:19)
at Parser.parse (/src/server/node_modules/handlebars/dist/cjs/handlebars/compiler/parser.js:336:30)
at parseWithoutProcessing (/src/server/node_modules/handlebars/dist/cjs/handlebars/compiler/base.js:46:33)
at HandlebarsEnvironment.parse (/src/server/node_modules/handlebars/dist/cjs/handlebars/compiler/base.js:52:13)
at compileInput (/src/server/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:508:19)
at ret (/src/server/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:517:18)
at Object.http.request (/src/server/lib/scene/scene.actions.js:250:76)
at executeAction (/src/server/lib/scene/scene.executeActions.js:32:35)
at /src/server/lib/scene/scene.executeActions.js:66:13
at tryCatcher (/src/server/node_modules/bluebird/js/release/util.js:16:23)
at MappingPromiseArray._promiseFulfilled (/src/server/node_modules/bluebird/js/release/map.js:68:38)
at MappingPromiseArray.PromiseArray._iterate (/src/server/node_modules/bluebird/js/release/promise_array.js:115:31)
at MappingPromiseArray.init (/src/server/node_modules/bluebird/js/release/promise_array.js:79:10)
at MappingPromiseArray._asyncInit (/src/server/node_modules/bluebird/js/release/map.js:37:10)
at _drainQueueStep (/src/server/node_modules/bluebird/js/release/async.js:97:12)
at _drainQueue (/src/server/node_modules/bluebird/js/release/async.js:86:9)
at Async._drainQueues (/src/server/node_modules/bluebird/js/release/async.js:102:5)
at Immediate.Async.drainQueues (/src/server/node_modules/bluebird/js/release/async.js:15:14)
at processImmediate (internal/timers.js:464:21)
Can you confirm that you are actually running the scene by launching the scene? Not by clicking « Try »? (that won’t work as stated in the description)
In your expression, if you have spaces, mathjs returns an error.
If you’re on mobile and you add a variable in a gladys block, I’ve noticed that it always adds a space after it.
Try removing the spaces in case that’s where it’s coming from.
However, the request sent does not contain the variable’s value, only an expression of the form {{0.0.last_value}}, which is why mathjs returns an error.
That’s fine, indeed I was testing with the ‹ Try › button. And I also confirm that you need to remove the spaces, otherwise there is no calculation result.
Thank you for the information and for your responsiveness.
Hi, as mentioned here, I started looking into being able to perform calculations directly in scenes. I’m doing this on the « condition » and « control a device » blocks — here’s what it looks like so far
Now I need your help. Quick explanation: once the variables are replaced by values during the execution of the scene, we use the mathjs library to perform the calculation. The problem is that the evaluate() method could allow injecting unwanted JS code into Gladys, so we must restrict this method to the mathematical functions that we really want to use in Gladys. By default, we’ll have at least the standard operators +, -, *, /. What other mathematical functions would you like to use (or already use with the mathjs API)?