Looking to set a dynamic slider range

Hi there,

I’m trying to configure a thermostat with a slider with a range that would change dynamically depending of the unit format (°C or °F).

The thermostat has a range in Celsius of 3 to 30 and a range in Fahrenheit of 37 to 86.

I tried the following code within the tiles definition but no luck so far, the resulting range is always to Fahrenheit one (37 to 86).

Any help in creating a dynamic range for a slider would be appreciated!

    def locationScale = getTemperatureScale()
    def maxTemp
    def minTemp
    if (locationScale == "C") {
        maxTemp = 30 // Max Temp in C
        minTemp = 3 // Min Temp in C
        log.trace "Location is in Celsius, MaxTemp $maxTemp, MinTemp $minTemp"
    } else {
        maxTemp = 86 // Max temp in F
        minTemp = 37 // Min temp in F
        log.trace "Location is in Fahrenheit, MaxTemp $maxTemp, MinTemp $minTemp"
    controlTile("heatSliderControl", "device.heatingSetpoint", "slider", height: 1, width: 2, inactiveLabel: false, range:"($minTemp..$maxTemp)") {
        state "setHeatingSetpoint", action:"quickSetHeat", backgroundColor:"#d04e00"

Suggestion: set the scale to be 0–>100, then use that as a percentage to calculate the effective setting from the range you are using, and then do a separate sendEvent to a different tile to show/display the selected/calculated temperature with a scale indicator

sendEvent( tempDisplay, “${calculatedTemp} F”, changed: true)

1 Like

@storageanarchy, thanks for the suggestion.

But am I right to think that this solution would allow the user to see the 0-100 value over the slider while sliding the bar?
I would prefer the actual setpoint value to be displayed on top of the slider rather than a percentage.

Am I right or am I missing the obvious?

you are correct, it was just a suggestion.

You may not be able to do what you want, although the fact that you are getting 37-86, then the logic is doing something. So you might want to verify that locationScale is actually getting set to “C” when you expect it to be.

Another approach would be to use 3 separate tiles for this: and up button tile, a down button tile and a tempDisplay tile… @yvesracine uses this approach in his custom Ecobee device.

Just trying to offer some ideas - hopefully you can get it working!

I pretty certain this cannot be set dynamically.

Device Detail Tiles have very limited dynamic features (in fact, there 2 other active Topic threads with related requests right now!). You can pretty much only change the display value based on an Attribute value, and only for certain tile types.

Thanks guys.

This confirms my evaluation.

I guess I will need to wait for ST to add more flexibility on Tiles.

1 Like