Why not compare two values?
I don’t know if it’s relevant.
For example, compare the setpoint temperature value and the temperature value in the room.
Then if the two values are equal we stop the heating.
I don’t know if it’s feasible.
Maybe also rounding and modulo?
Yes indeed
I don’t know if you saw in the screenshot, I planned to add in this PR the ability to put variables in the value of the « Continue only if » block, isn’t that what you’re asking for?
Yes, we can add round to nearest, round up and round down — it could be useful to have all three. Good point about modulo, I’ll note it
It’s not necessarily a request for me, but the « continue only if » is correct.
To expand on conditions, there are the conditional expression operators in mathjs ? : like the ternary in JS — this will allow making pseudo if…else within an action.
More broadly, regarding adding calculations into scenes, I think we should allow all operators and limit the mathjs functions (the ones we call with parentheses and parameters; that’s where security issues can appear)
The PR is here
The code allows using variables and performing calculations in scenes for the « continue only if » and « control a device » blocks (see screenshots a bit above)
If you want to run tests, an image is available here bertrandda/gladys:scene-var-eval
Thank you for the work @bertrandda
It’s really great!
I’ve left you some feedback on the PR : https://github.com/GladysAssistant/Gladys/pull/1742#pullrequestreview-1395209378
It’s fixed
The image bertrandda/gladys:scene-var-eval is up to date
@bertrandda I don’t know if you had seen my feedback? ![]()
Yes, I saw it, but I haven’t had time to sort all that out yet; I’ll try to do it tonight.
All good, your feedback has been addressed and the Docker image is up to date.
@bertrandda Thanks for the feedback, it’s perfect like this
Great job, it’s very clear and it works great! I tested it live, I didn’t find any bugs ![]()
It’s merged into master and it will be included in the next Gladys release.
Awesome!! ![]()
I was fed up that every time my connection dropped, my call to mathjs would fail in my scenes!
Quick question:
Could the result be used to ‹ control a device ›?
Yes
Look at my screenshot above
Good evening,
Great — can’t wait to test it, it should help me with heating management, even if it’s less relevant for the moment ![]()
.
@bertrandda Is it possible to perform the operations on 2 variables?
Thanks for this dev
Yes, you can include multiple variables in the same calculation, provided that your variable is declared earlier in the scene (via a request or a « get value » block).
For my part, I have a calculation use case that I imagine is impossible at the moment.
I would like my pool pump to run for x time (in hours).
In this case: x = température eau / 2
Would it be technically possible in the future to use the result of these calculations in other types of blocks?
Simply put:
- turn on the pump
- wait X hours
- turn off the pump
@bertrandda For info, @AlexTrovato found a regression in this feature — if a device control ever sent a value equal to 0 (very likely, because 0 is « OFF » for all devices), the scene would stop ![]()
Fortunately it didn’t make it to production and he made me a PR in time!
Thanks @AlexTrovato!
The fix: Fix zero as a number by atrovato · Pull Request #1773 · GladysAssistant/Gladys · GitHub


