[SOLVED] Switch Item in Sitemap with visible percentage value

  • Platform information:
    • Hardware: _Raspberry Pi 3
    • OS: openHABian 2.4.0
    • KNX Binding

Hello,

I think I have a very beginner question - but I don’t know how to do it correct. I’m very new in programming with openHAB. I already searched in other Topics but didn’t find an answer.

My configuration has three Switch elements on the sitemap to move my rollershutters in position:

Switch item=GF_LivingRoom_ShutterLeftPosition mappings=[25="25%", 50="50%", 75="75%"]
Switch item=GF_LivingRoom_ShutterMiddlePosition mappings=[25="25%", 50="50%", 75="75%"]
Switch item=GF_LivingRoom_ShutterRightPosition mappings=[25="25%", 50="50%", 75="75%"]

The items for the three are defined e.g. like this:

Number          GF_LivingRoom_ShutterRightPosition   "Rolladen rechts - Höhe anfahren"   <rollershutter>      (GF_LivingRoom, gShutter)          ["Rollershutter"]                  {channel=""}

That the boxes of the Switch are unchecked after every click of the button, I made this rule:

rule "Rolladen Position anfahren"

when
      Item  GF_LivingRoom_ShutterLeftPosition received update or
      Item  GF_LivingRoom_ShutterMiddlePosition received update or
      Item  GF_LivingRoom_ShutterRightPosition received update
then
        if(GF_LivingRoom_ShutterLeftPosition.state != NULL)
        {
            GF_LivingRoom_ShutterLeft.sendCommand(GF_LivingRoom_ShutterLeftPosition.state)
            GF_LivingRoom_ShutterLeftPosition.state = NULL
        }

        if(GF_LivingRoom_ShutterMiddlePosition.state != NULL)
        {
            GF_LivingRoom_ShutterMiddle.sendCommand(GF_LivingRoom_ShutterMiddlePosition.state)
            GF_LivingRoom_ShutterMiddlePosition.state = NULL
        }

        if(GF_LivingRoom_ShutterRightPosition.state != NULL)
        {
            GF_LivingRoom_ShutterRight.sendCommand(GF_LivingRoom_ShutterRightPosition.state)
            GF_LivingRoom_ShutterRightPosition.state = NULL
        }
end

My problem now is: Everything works fine but in the sitemap I always get the percentage of the item (marked yellow):

grafik

Can somebody explain why I get the %-value and is it possible to make it invisible?

Thanks in advance.

Rainer

What does your sitemap file look like?

Here you can se an extract of the sitemap file:

        Text label="Wohnzimmer" icon="sofa" {
			Frame label="Licht" icon="light" {
                Slider item=GF_LivingRoom_Light
            }
            Frame label="Steckdosen" icon="poweroutlet" {
                Switch item=GF_LivingRoom_Power_TVRightLeft
                Switch item=GF_LivingRoom_Power_TVRightRight
                Switch item=GF_LivingRoom_Power_VitrineLeftLeft
                Switch item=GF_LivingRoom_Power_VitrineLeftRight
                Switch item=GF_LivingRoom_Power_TVMiddleMiddle
                Switch item=GF_LivingRoom_Power_TVMiddleRight
                Switch item=GF_LivingRoom_Power_VitrineMiddle
                Switch item=GF_LivingRoom_Power_VitrineRight
                Switch item=GF_LivingRoom_Power_Fensterfront_Vit
                Switch item=GF_LivingRoom_Power_Fensterf_Freis
            }
            Frame label="Rolladen" icon="rollershutter" {
                //Alle Rolläden
                Switch item=GF_LivingRoom_ShutterAll
                //Rolladen links
                Switch item=GF_LivingRoom_ShutterLeft
                Switch item=GF_LivingRoom_ShutterLeftPosition mappings=[25="25%", 50="50%", 75="75%"]
                //Rolladen Mitte
                Switch item=GF_LivingRoom_ShutterMiddle
                Switch item=GF_LivingRoom_ShutterMiddlePosition mappings=[25="25%", 50="50%", 75="75%"]
                //Rolladen rechts
                Switch item=GF_LivingRoom_ShutterRight
                Switch item=GF_LivingRoom_ShutterRightPosition mappings=[25="25%", 50="50%", 75="75%"]
            }
            Frame label="Heizungssteuerung" icon="flow" {
                Default item=GF_LivingRoom_Temperature
                Default item=GF_LivingRoom_SollTemperature //minValue=4.5 maxValue=30 step=0.5
                Selection item=GF_LivingRoom_SollVerschTemperature mappings=[-3="-3°C", -2.5="-2.5°C", -2="-2°C", -1.5="-1.5°C", -1="-1°C", -0.5="-0.5°C", 0="keine", 0.5="+0.5°C", 1="+1°C", 1.5="+1.5°C", 2="+2°C", 2.5="+2.5°C", 3="+3°C"]
                Selection item=GF_LivingRoom_Heating mappings=[1="Komfort", 2="Standby", 3="Nacht", 4="Frostschutz"]
                Default item=GF_LivingRoom_Window
                Text item=GF_LivingRoom_StatusStellwert
            }
		}

Add "[]" as the label in the sitemap element:

Switch item=GF_LivingRoom_ShutterLeftPosition "[]" mappings=[25="25%", 50="50%", 75="75%"]
Switch item=GF_LivingRoom_ShutterMiddlePosition "[]" mappings=[25="25%", 50="50%", 75="75%"]
Switch item=GF_LivingRoom_ShutterRightPosition "[]" mappings=[25="25%", 50="50%", 75="75%"]

Also,
Why do you do that?

GF_LivingRoom_ShutterLeftPosition.state = NULL

For what purpose?

Thank you for the reply.

I found no other way to uncheck the 25%, 50% and 75% buttons after clicking them.

When I do that on the sitemap the console says:

14:41:29.106 [WARN ] [del.core.internal.ModelRepositoryImpl] - Configuration model "myhouse.sitemap' has errors, therefore ignoring it: [52,63]: mismatched input '"[]"' expecting '}'
[55,65]: mismatched input '"[]"' expecting '}'
[58,64]: mismatched input '"[]"' expecting '}'
[60,13]: missing EOF at 'Frame'

My apologies:

Switch item=GF_LivingRoom_ShutterLeftPosition label="[]" mappings=[25="25%", 50="50%", 75="75%"]
Switch item=GF_LivingRoom_ShutterMiddlePosition label="[]" mappings=[25="25%", 50="50%", 75="75%"]
Switch item=GF_LivingRoom_ShutterRightPosition label="[]" mappings=[25="25%", 50="50%", 75="75%"]
GF_LivingRoom_ShutterLeftPosition.state = NULL

This would be a more correct syntax:

GF_LivingRoom_ShutterLeftPosition.postUpdate(NULL)

Why use Item type Switch instead of type Rollershutter ?

Because of historical reasons. Before I had the rule I used the KNX-Binding to move to the position directly with an own item instead of using the item.sendCommand() of the already existing rollershutter item.
But you’re right - now that I use .sendCommand() I can change it back to type ‘Rollershutter’.

1 Like

Thank you! That worked for me. Perfect :hugs:

I now only have the problem that the alignment of all objects is different:

grafik

Is it possible to harmonize them?

Remove [] from labels?

I’m surprised you get any label text at all with sitemap label="[]"
You could give the label text in the sitemap, or put the null state formatter [] in your Item label and take away the sitemap parameter.

2 Likes

What about defining the label in the sitemap?

Switch item=GF_LivingRoom_ShutterLeftPosition label="Rolladen links - Hohe anfahren []" mappings=[25="25%", 50="50%", 75="75%"]

Sorry I don’t have the same characters

2 Likes

Another thing: You don’t need to postUpdate(NULL) to the Item Instead set the Item to autoupdate=“false”

Number GF_LivingRoom_ShutterRightPosition "Rolladen rechts - Höhe anfahren" <rollershutter> (GF_LivingRoom, gShutter) ["Rollershutter"] { channel="", autoupdate="false" }

This way the Item will not change its status when sending a command.
But in fact there is no reason for this rule and the proxy items.

1 Like