Levelslidercontrol


(MJ) #1

Does the levelslidercontrol respond to level updates?

    controlTile("levelSliderControl", "device.level", "slider", height: 1, width: 3, inactiveLabel: false) 
    {
		state "level", action:"switch level.setLevel"
    }

What I mean, if in the on() method, if I

            sendEvent(name: "switch", value: "on")
            sendEvent(name: "level",  value: 100)
            sendEvent(name: "switch.setLevel", value: 100)

Should the slider get moved over to the far right? I am trying to understand the behavior. Or am I doing something wrong.

Michael.


(Ron) #2

I should work that way. Your seconds event which sets “level” should work. Have a look at my samples below.

Are you using Android or iOS ? I wrote this code to test sliders on my Android 1.7.2 version due to a bug I found in this release when you are limiting the slider to a smaller range of numbers. The bug is that the slider does not initialize when first displayed based on the current value if you are not using the 1-100 range. But your question about setting position when the event is sent should work.
NOTE: color setting is also broken as of Android 1.7.2 so setting the slider color doesn’t work and you just get the default blue slider.

Take a look at my sample code here. You can install this device in the ide and play with it to see how it works. When you tap on the number value tiles it should increment the number by 1 and you should see the slider move.

or for a real world example you can have a look at this code which I added two sliders to for temperature control on a ir sender device I have.


(MJ) #3

Thanks Ron. I was using the simulator/IDE. When I looked on my phone, it did work.