Feature Request: Add MIN() and MAX() functions to Variable Math

Because there are times when you want to provide upper or lower bounds on a variable's value, it would be helpful to have MIN(a,b) and MAX(a,b) at our disposal.

I realize the list of available mathematical operations has been kept pared to the most basic and oft-used variety, with further limitations imposed by the Rule Machine UI (e.g. favoring binary operators over open-ended ones like avg(a,b,c,d,...)). And it goes without saying that fancy calculations could be done using Hub Variables in the context of, say, WebCoRE, etc.

But a simple MIN(a,b) and MAX(a,b) (and, heck, why not AVG(a,b)) could simplify instances where you need to place limits on values -- for example, the HeatSetpoint for a Thermostat, which should not exceed MaxHeatSetpoint. I assume they would also be simple to implement from a coding perspective.

Thanks!

Adding MIN(a,b) as opposed to MIN(a,b,c,d,...) doesn't make a lot of sense. You can easily test two values with IF-THEN-ELSE so this isn't buying you very much (given that the underlying code is just going to do the same comparison). I'm somewhat averse to feature creep when there's a straight forward way to do something already. And I'm not up to adding open-ended math operators.

So use WebCore.

1 Like

Download the Hubitat app