Math with variables?

Addition of variables is great! I know they are new, so this might be asking too much. I have two humidity sensors and I’d like to report the average of the two relative humidity values on my dashboard. I see where I can a variable equal to a sensors RH value. Is there anyway, for example, to set a variable equal to (RH1+RH2)/2, where RH1 and RH2 are the humidity values reported by the two sensors?

1 Like

:tada: Update: Math and Date Expressions are now available! :tada:

Math and Date Expressions
https://community.sharptools.io/t/math-date-expressions/10368?u=josh

@kbhousen , simple math is something I’ve been thinking about so it’s great to see some use cases. Thanks for the suggestion.:+1:

2 Likes

I have some battery sensors that report in mV, so like 12,440mV. Haveing some math would be good so I can convert to display in volts, like 12.4v. I voted yes.

2 Likes

Another use of math in variables would be to raise/lower intensity level of bulbs.

Example: successive presses of a “Dim” switch would reduce the level by 10,

3 Likes

Upvoting this per my thread in the Beta forum: https://community.sharptools.io/t/beta-context-variables-variables-in-notifications/5290/21?u=tagyoureit

I would have upvoted this but it’s apparently maxed out. My math wish is for ‘if current value is less than [some number, e.g. 20] of the current value’. I was trying to implement this as ‘device attribute is < (variable - 20)’ where I put that same device attribute value into that variable sometime earlier. Thanks! Good luck.

1 Like

Hi @James, seems like this has been on the “hit list” for a while.
Any update?

For use cases I’d really like to be able to average out temps in a room as well as set controllable objects like bulbs and fans to calculated values.
As a suggestion and perhaps ease of implementation, you could look at how scratch implements basic math.

Thx!

3 Likes

@JediBob, thanks for the follow up. I am currently working on another feature request that has more interests casted. But I agree, this variable math feature can be very helpful in many cases. So I will have to circle back on this one and let’s see if we can catch more votes here.

I keep running into situations where just simple math in variables - addition and subtraction - would be useful. For example, “three doors are unlocked”.

Wanted to see if a nudge would budge the “hit list” …

2 Likes

Just saw this new request for string conditions and figured I would share it here too in case anyone wants to vote on it since it seems like a relevant rule logic feature. Add string functions to flow conditions

1 Like

Would like to see this for things like displaying current crypto value. I can get the market value from an api call but then I want to see that times the number of coins that I own to see the current profit/loss.

Bumping this. I want to create a rule that when humidity increases by 10% an exhaust fan is turned on.

2 Likes

i hope “bumping” helps. I’ve only been “nudging”…

3 Likes

Went to add two numbers together today and was surprised to find this was not an existing capability. Upvoting.

2 Likes

+1 from me. Would love this.

Any update on this feature request?

Also hoping for this. I want to be able to increase my thermostat’s set temperature if my pet’s enclosure gets too cold.

Thanks for sharing your use-case. It’s at the top of our hit list to revisit after we wrap up some of the Next Gen SmartThings work!

If it’s urgent, I have an approach that could work for you in the meantime. :wink:

1 Like

Fantastic, thank you!!
You have my interest haha. What’s the workaround you’re thinking of?

Side note, you have an awesome name!

SpiderManGIF

Sending you a PM. :slight_smile: