Control blinds with potentiometer reading

  • Platform information:
    • Hardware:Rpi 3b
    • openHAB version: 2.4

Hello good Morning. I have the shutters running with a switch (up, down) and also with Astro that when the sun goes down, add an offset of 20 minutes and lower the shutters of my house.
So far right, but now with the arrival of summer I would like to control the% opening.
I mounted a multivolt potentiometer with a strap in the blinds motor, and it graduates from 0% (totally open) to 100% (totally closed).
The point is that I would like to have a slider where the jump is 10% to be able to control the position of the blind if I want 50% closed or 70% closed.
Since all the attempts were failed I have tried to start with a 3-position switch where the intermittent position does not work and now it does not work either of the three.
Attach what I have and if someone can help me to migrate to a slider.

Rule:

rule “Persiana 3 Posicions”
when
Item Selector_Persiana_Pasillo changed //changed command on switch
then
var OberturaPersiana = Posicio_Passadis.state as Number // Posicio_Passadis is a potentiometer
switch (Selector_Persiana_Pasillo.state.toString) {
case “0” : {
Persiana_Pasillo.sendCommand(UP) // Persiana_Pasillo is a motor roller shutter
sendTelegram(“bot1”,“Passillo 0% (obert)”) // comand to chek te operation (same as port serial)
}
case “1” : MyItem.sendCommand(ON)
if(OberturaPersiana.state < 50.0){
Persiana_Pasillo.sendCommand(DOWN)
sendTelegram(“bot1”,“Baixant per 50%”)
}
if(OberturaPersiana.state > 50.0){
Persiana_Pasillo.sendCommand(UP)
sendTelegram(“bot1”,“Pujant per 50%”)
}
if(OberturaPersiana.state == 50.0){
sendTelegram(“bot1”,“Passillo 50%”)
}
case “2” : {
Persiana_Pasillo.sendCommand(DOWN)
sendTelegram(“bot1”,“Passillo 100% (Tancat)”)
}
}
end

Sitemaps:

Switch item=Selector_Persiana_Pasillo label=“Posicio Desitjada” mappings=[0=“0%”, 1=“50%”, 2=“100%”]

Items:

String Selector_Persiana_Pasillo “Persiana Pasillo [MAP(3states.map):%s]”

Thanks.

Enric

Have you tried a slider in the sitemap?

Slider item=Selector_Persiana_Pasillo label=“Posicio Desitjada” [minValue=0] [maxValue=100] [step=10]

Or Selection

Selection item=Selector_Persiana_Pasillo label=“Posicio Desitjada” mappings=[0=“0%”, 1=“50%”, 2=“100%”]

Hi, I prefer a better slider, but I have no idea how to get its numerical values ​​from it to put in a rule that compares the two values ​​and goes up or down to have the desired value.
I had it done with a switch because I have no idea how to get the numerical value or how to do the operations for the position.
Thanks

Enric

Nobody got any idea?