[SOLVED] Sitemap - Group Value When Different ItemTypes

Hello

I’m kind of new in OpenHAB2 (V2.3) and i have a question/problem.
I would like to show the temperatur of my groups in the BasicUI. For the group with only types of “Number” it’s working. When I mix “Number” and e.g “Switch” in BasicUI if have only “- °C”.

Sitemap


  Frame label="Zimmer" icon="groundfloor" {
        Group item=Bedroom
        Group item=Kids_Bedroom
        Group item=Office
        Group item=Play_Room
    }

In items

Group    Bedroom                "Eltern Schlafzimmer [%.1f °C]"     <bedroom>       (Home)  { channel="mihome:sensor_weather_v1:xyz:temperature" }
Group    Kids_Bedroom           "Kinderzimmer [%.1f °C]"            <girl_3>       (Home)  { channel="mihome:sensor_weather_v1:xyz2:temperature" }

Item Bedrom


Number   Bedroom_Temperature    "Temperatur"        <temperature>    (Bedroom)           { channel="mihome:sensor_weather_v1:xyz:temperature" }
Number   Bedroom_Humidity       "Feuchtigkeit"      <humidity>       (Bedroom)           { channel="mihome:sensor_weather_v1:xyz:humidity" }
Number   Bedroom_Pressure       "Luftdruck"         <pressure>       (Bedroom)           { channel="mihome:sensor_weather_v1:xyz:pressure" }
Number   Bedroom_Battery        "Batterie"          <battery>        (Bedroom)          { channel="mihome:sensor_weather_v1:xyz:batteryLevel" }

Item Kids_Bedroom

Number   Kids_Bedroom_Temperature    "Temperatur"        <temperature>    (Kids_Bedroom)           { channel="mihome:sensor_weather_v1:xyz2:temperature" }
Number   Kids_Bedroom_Humidity       "Feuchtigkeit"      <humidity>       (Kids_Bedroom)           { channel="mihome:sensor_weather_v1:xyz2:humidity" }
Number   Kids_Bedroom_Pressure       "Luftdruck"         <pressure>       (Kids_Bedroom)           { channel="mihome:sensor_weather_v1:xyz2:pressure" }
Number   Kids_Bedroom_Battery        "Batterie"          <battery>        (Kids_Bedroom)           { channel="mihome:sensor_weather_v1:xyz2:batteryLevel" }
Switch   Kids_Bedroom_Switch         "(Ein / Aus)"                        (Kids_Bedroom)           { channel="tradfri:0210:gwb8f2bdfgdd2f:65545:color" }

With a switch in the “Group Kids_Bedroom” there may be a problem with transformation of [%.1f C].
Have you tried to remove the switch from the group by deleting (Kids_bedroom) from the switch line and just add it to sitemap like Switch item=Kids_Bedroom_Switch?

Frame label="Zimmer" icon="groundfloor" {
        Group item=Bedroom
        Group item=Kids_Bedroom
        Group item=Office
        Group item=Play_Room
        Switch item=Kids_Bedroom_Switch
    }

and items

Number   Kids_Bedroom_Temperature    "Temperatur"        <temperature>    (Kids_Bedroom)           { channel="mihome:sensor_weather_v1:xyz2:temperature" }
Number   Kids_Bedroom_Humidity       "Feuchtigkeit"      <humidity>       (Kids_Bedroom)           { channel="mihome:sensor_weather_v1:xyz2:humidity" }
Number   Kids_Bedroom_Pressure       "Luftdruck"         <pressure>       (Kids_Bedroom)           { channel="mihome:sensor_weather_v1:xyz2:pressure" }
Number   Kids_Bedroom_Battery        "Batterie"          <battery>        (Kids_Bedroom)           { channel="mihome:sensor_weather_v1:xyz2:batteryLevel" }
Switch   Kids_Bedroom_Switch         "(Ein / Aus)"                                   { channel="tradfri:0210:gwb8f2bdfgdd2f:65545:color" }

like that it’s working. but then the switch is not in the group “Kids_Bedrooom” anymore.

Not being nosy but is there a reason the switch must be in that group? I can see having all temps in a group so they can be averaged, or all switches in a group so all can be turned on/off with one command.

There is nothing to stop you having Items in both of two groups, one for the temperature/number work and one for whatever purpose you need the switch as well.

If you are using the group as a convenience for display in a UI, you’ll probably find like many before you that you will abandon that - it doesn’t give you much control over display order etc.

How did you get it to show a value from the group in the sitemap?

@Kim_Andersen: I did it in the Items file like that:

Group    Bedroom                "Eltern Schlafzimmer [%.1f °C]"     <bedroom>       (Home)  { channel="mihome:sensor_weather_v1:yxz:temperature" }

@rossko57: yes, I thought Groups would be the right thing to build my UI :blush: . But in that case I have to rethink it and have to search another approach.

@H102: hmmm… actually I thought it would be nice to have a Group by Room. And then in each Room all that devices as tempsensors, hue lamp, smart power adapter etc.

1 Like

Groups do give you a quick and easy way to start a UI. There aren’t many quick and easy things in OpenHAB!
It just doesn’t offer the flexibility of display many people eventually require - ordering items, visibility options etc. To get that you have to build your sitemap in the tedious line by line way.

Grouping by room is fairly standard practice. Don’t forget you can do things like have an Item both in a room group and in a sensors group.

hi folks

thank’s all for your help!! i was somwhow not aware, that i can also “group” text item / switch item e.g. in sitemap. I did it now without groups and it works like a charm.

Text item=Kids_Bedroom_Temperature icon="girl_1" label="Kinderzimmer [%.1f °C]" {
           Text item=Kids_Bedroom_Temperature
           Text item=Kids_Bedroom_Humidity
           Text item=Kids_Bedroom_Pressure
           Text item=Kids_Bedroom_Battery
           Switch item=Kids_Bedroom_Switch
           Default item=Kids_Bedroom_Brightness
           Default item=Kids_Bedroom_Lamp
        }

Ahh the trick is to use group definition in the item file, ofocuse… Thanks for clearing this :slight_smile:

by using this nested syntax I got a loading error for the sitemap

Well, we can’t see the error or your sitemap. It does work for other people.

My usual mistake is messing the { } pairing throughout the sitemap.