Group:Contact vs Group:Switch

This drives me crazy…
I spent the last couple of hours to figure this out…

I have these activegroups:

Group:Switch:OR(ON, OFF)    gHouse_Lights    "All Lights [(%d)]"             (gHouse)
Group:Contact:OR(OPEN, CLOSED)     gHouse_Windows    "Open Windows [(%d)]"    <contact>    (gHouse)
Group:Contact:OR(OPEN, CLOSED)     gHouse_Doors    "Open Doors [(%d)]"    <contact>    (gHouse)`

Lights look like this:

Switch Light_House_Plant_Room_L        "Plant Room Left"    (gHouse_Plant_Room, gHouse_Lights)
Switch Light_House_Plant_Room_M        "Plant Room Mid"    (gHouse_Plant_Room, gHouse_Lights)
Switch Light_House_Plant_Room_R        "Plant Room Right"    (gHouse_Plant_Room, gHouse_Lights)

Windows like htis:

String Door_House_Plant_Room_External         "Plant Room [MAP(en.map):%s]"        <door>        (gHouse_Plant_Room, gHouse_Doors)            {mqtt="<[mymosquitto:ArgyleCourt/House/Plant/Door/External:state:default]"}

I had to change the item form Contact to String, otherwise it would throw an error:
given new state is NULL, couldn't post update for 'Door_House_Plant_Room_External'

sitemap:

    Switch item=gHouse_Lights           mappings=[OFF="All Off"]
    Group  item=gHouse_Windows
    Group  item=gHouse_Doors

UI looks like this:

Questions:
What should the correct group type be for the active groups (Group:Switch|Contact)
Why do the lights count, but neither windows nor doors?

1 Like

What are the values that are being sent via MQTT? If it is sending 0/1 or “CLOSED”/“OPEN” it should work as a switch just fine. One thing that trips people up is trailing whitespace when using numbers. For example, “0” would work just fine but "0 " would error with a NULL exception like you see there.

I can’t say for sure what the problem is but I don’t know how well the counting et. al. works if all the data members are not the same type and/or are a different type than the Group.

So I’d guess the primary problem is that using a String Item in a Group:Contact would not work for counting and that the OR clause probably won’t work either.

As always thanks for caring! :slight_smile:

… are: open | closed

send via terminal command line to MQTT:

mosquitto_pub -d -t ArgyleCourt/House/Entrance/Door/External -m "open"

it works for the Switch, but not for the Contact, which are aggregated in my sitemap by
Group item=gHouse_Doors

and in the demo sitemap as
Group item=Windows

my item:
Contact Door_House_Entrance_External "Main Entrance [MAP(en.map):%s]" <door> (gHouse_Entrance, gHouse_Doors) {mqtt="<[mymosquitto:ArgyleCourt/House/Entrance/Door/External:state:default]"}

demo item:
Contact Window_GF_Toilet "Toilet [MAP(en.map):%s]" (GF_Toilet, Windows)

I have modified my .items, made them all contact, and now commented out all, but one door (shown), which I open and close with the terminal command as described above (no trailing spaces), and cannot figure why it would not count on the sitemap??!
→ now being the same as the demo (which works). I have no rules pertaining the doors.


I have just tried to send a “0”… which did not work either.
BUT, I sent “OPEN” and that worked! WHAT?

my en.map looks like this:
CLOSED=closed closed=closed OPEN=open open=open undefined=unknown -=undefined

What is going on here?


Huh… and it is counting now too?
I need to understand this… HELP! what is going on here? I do not get this into my head?

I also changed the order in en.map to lower open and upper OPEN, which did not make a difference.


I have a text file with these MQTT commands, which I cut and paste as required into the terminal. Works well.
So, sending now 14 OPEN and then CLOSED commands in uppercase works for the status and counting; despite 13 being a CONTACT and 1 being a STRING.

Still, I don’t get it. I remember that I had initially only uppercase (open|closed) in the en.map and added the lowercase words, because I had some transform error, (but can’t remember when that was).

Yes, sadly it is case sensitive in this case apparently.

When you use a MAP in the label, it only applies to the label. It only changes how it appears on your sitemap. The Item’s actual statesis still OPEN. The map converts OPEN to some other string for display only.

It is only when you use a MAP as a transform (I.e. when it is between the curly brackets as part of the binding config) that it will transform incoming data into a format that OH understands and can convert to an Item’s state.

If you want to convert “open” to OPEN, you would replace the default part of the MQTT binding with the map transform.

2 Likes

Aha… got that.
Thank you very much for taking the time to look at my quirky issues… maybe I am more quirky than the issues :slight_smile:

This helped me solve a different problem - thanks!