Specify ControlTile Range

Can we specify min and max values in a controlTile for a custom device type?
Apologies if this is not in the right forum.

Bump to see if anyone knows this.
Usage case example: Thermostat temperature range is only from (40 through 90F).
@Ben, is this supported?

You can do this in code easy. Apply slider values to your own range or just a simple if statement.

If slider < 40 slider = 40 and same for max

@pstuart Do you mean adding the range in the preferences section, or applying a range after selection has been made? (I would like to do the former.). Can you please provide a code snippet if it is indeed the former you are referring to? Thanks.

if you add two values either in a preference or hard coded the code isn’t that hard to map the range of 1 to 100 from the slider to your custom values:

Assuming tempF is the slider value
privMin is your new minimum value
privMax is your new maximum value

def newtempF = (((tempF.toInteger() - 1) * (privMax.toInteger() - privMin.toInteger()) / (100/1) + privMin.toInteger()))

This will map tempF to newtempF and constrain it in the range of privMin to privMax

Hope that helps.

@pstuart thanks for the snippet, this seems to be achieving the former (forcing the range after selection).
However, if I need to change the temperature to 65deg, and my thermostat supported range is [40, 90]deg, then I need to change the slider to 50 (since the range is 0-100 to achieve this. Not very intuitive, it will be easier if ST can also support a control tile with some privMin, privMax values.

1 Like

So just set it then.

If (tempF < tempmin) tempF = tempmin
If (tempF > temp max) tempF = tempmax

That way all slider values will map to range.

But my previous way expands the sensitivity of the slider. Since android doesn’t support horizontal sliders.

If st supported a min and max it would compress the range like my code. All sliders do that. If you want to truncate the values just do two simple If statements.

@pstuart May be I am not explaining the issue completely …
There is a tooltip that appears (at least in Android) in the controlTile when dragging the slider.
I want to be able to drag the slider to 65 (based on the tooltip) and then be able to set the temperature to 65.
My slider should not drag below 40 (40deg) or above 90 (90deg).

Yeah nothing can be done that way. Most sliders work off min and max starting values at the endpoints.

You want a range of 1-100 but start at 40 and stop at 85.

Best I can do is work with how sliders work and at least give you more range.

The tooltip is a problem as well.

Maybe someday st will give us ui controls but their goal is not ui/ux but automation.

I agree the slider should have more options. It’s kind of ugly. :smirk:

  1. Background color should work
  2. Should be able to have a label on it
  3. Should be able to show the current value on it (like it does while adjusting)
  4. And yes, the range should be an option
1 Like

The tool tip makes this method useless. It is completely unusable to slide a slider and have it displaying values 0-100 while you slide only to have the value that is issued to be some value between a range.

The technique is common in sliders but the tool tip must display the value AFTER it is converted to the range not before.

I tried this for a temp slider and it was much worse then just forcing the min/max.

Forcing min/max seems strange because in my case I need a value between 19-28. So the user has to manipulate a 0-100 slider on a small screen to try to select a value 19-28.

ST focusing on automation and not UI is a mistake. If the UI is horrible users will move elsewhere. Both are important and must be managed at the same time.

I totally agree with @drandyhaas but would put them in priority order of

  1. ability to have tooltip display limited range (I don’t care if 0-100 is returned as long as the tool tip displays after range conversion is done.
  2. Display current value. I have to waste a tile to display the current value so sliders always take three tiles.
  3. Label would be nice
  4. background color setting would also be nice

Obviously a reply to a very old thread. Updating should anybody be looking for an answer to this one I was a couple of days ago).

This is now possible, something obviously changing on the back end to support it.

Example shown below:

    controlTile("heatSliderControl", "device.heatingSetpoint", "slider", width: 6, height: 1, inactiveLabel: false, range:"(5..28)") {
    state "setHeatingSetpoint", action:"quickSetHeat", backgroundColor:"#d04e00"
1 Like

@brumster This has been working for quite some time.

Thanks @Ron.

I simply wanted to update the thread in case anyone went looking for answer before reading the dev docs (like I did).

1 Like