Perform a mathematical operation on a "scene variable"

As a user
I want to be able to add, subtract, multiply, divide a scene variable
In order to be able to perform more complex calculations in the scenes

Great idea, this could be interesting in many scenarios!

You mean this?

I suggest modifying it to also take your case into account and merging the votes :slight_smile:

Pi @lmilcent

Sure, here’s your vote :wink:
Anyway, that’s exactly what I need, to perform calculations on the data retrieved from the scenes!

Haha :wink:
We could do mergers yes because some people wanted that too ^^

Your PR requests quite a bit, for example « average of values over a period Â», which is a substantial development task.

This is not at all what we are talking about here ^^

Here, we are just talking about taking a sensor value that we already have in the scene, and doing +1, x2, -4, /5.

Is your PR still relevant then?

I see. Indeed, we need to clearly define the two feature requests in this case!
Both are my needs, but especially what is not within the scope of this request :sweat_smile:

That’s why feature requests must be very specific and list exactly what is expected :slight_smile: Otherwise:

  • No one votes because the request is not understood
  • Even I don’t understand what to develop :stuck_out_tongue:

I’m bumping this thread to share my view on the matter; maybe concrete examples can guide people.

My use (at least the first for now) would be for the operation of my swimming pool.
Currently I control the pump’s start/stop from a scene that is defined with fixed schedules.
However, it is recommended to set a pump’s running time according to the water temperature. If I simplify, you have to divide the temperature by 2 to know how many hours the pump should run per day. This prevents the water from turning green if it doesn’t run enough / saves money if you avoid it running for no reason!

Being able to perform calculations is an important starting point for this use. Because if the water temperature drops quickly / rises quickly, I don’t want to modify my scene constantly, it would adjust itself.

For me Gladys can only move in the right direction by giving concrete examples of the needs!
You did very well :slight_smile:

I’m wondering whether, in the meantime, there might exist an online API allowing you to perform a calculation and return the result?
Gladys being able to make API calls, that would almost allow doing without the functionality while it’s being developed.

[EDIT]
Well yes it exists:

I’ll have to look into that one of these days :sweat_smile:

Warning, Gladys cannot make GET API calls with arguments coming from sensors. But fortunately, there is a POST API and Gladys can then use dynamic arguments!

[EDIT]
@pierre-gilles: could this be a bug?
The sensor values are sent with the braces { (visible in the screenshot on the right).

The value is not substituted in the screenshot on the right :thinking:

Indeed, that’s a bug! Do you have what you need to reproduce the bug so you can open a GitHub issue?

Yes, I’ll do that for you.

[EDIT]

To me, your problem is normal according to the explanation below if you try it

And the body, apart from the variables, is not written correctly.

However, I haven’t tried with variables but only with values; I get the result but I get an error message

I’ll try later with variables when I’m at home.

But yes, of course, luckily I didn’t read it…

But the problem is that you can’t really know which variable to use later in the rest of the scene.

Replace your variable with a value that you’re supposed to have to know the result.
When you have the answer you can replace it back with your variable.