Group of ContactItems with function "COUNT" throws invalid state error

Hello!
Somehow I don’t have an idea what I am doing wrong here:

I have 4 Homematic contacts and all are defined like this:

Contact Tuer_EG_Eingang “Tür Erdgeschoss Eingang” (gKontakte) { channel=“homematic:HMIP-SWDO:raspiccu:0000D8A9AA9BC7:1#STATE_CONTACT” }

You can see, that they are all mapped to the group

Group:Contact:COUNT(“OPEN”) gKontakte “Kontakte (offen) [%d]”

with which I will count the number of open contacts.
I have added the group to a sitemap and everything works great. No problem. All contact state changes are reflected correctly.

But in the log viewer there are error entries, complaining of an invalid state type:

2020-06-23 12:32:09.024 [ERROR] [pse.smarthome.core.items.GenericItem] - Tried to set invalid state 2 (DecimalType) on item gKontakte of type ContactItem, ignoring it

So now, please help me, where is the mistake!?

Regards,
Jürgen.

If the Group subtype is Contact, it can take states OPEN or CLOSED, but not 2. That’s more suited to a Number.

Group types need not match member types, not least because member types can be mixed.

Your sitemap works because [%d] has a magical property when used with Groups, and provides a count to display. Even when no Group function is given. But you cannot control what it counts.

There is a nice little hidden feature of Groups. You can define a Group as Group:Number:SUM, fill it with Contacts, and the Group’s state will be the count of OPEN Items. The same works for Switch and the count will be of the ON Items.

So @juergen.mnich you can define your Group as:

Group:Number:SUM gKontakte “Kontakte (offen) [%d]”

Or, as rossko57 indicates, change the Group Type to Number.

Group:Number:COUNT(“OPEN”) gKontakte “Kontakte (offen) [%d]”

Thank you so much for your answers :slight_smile:

Just one little additional question: When I now change the group’s definition there is an entry in the log file:

2020-06-24 13:54:29.136 [WARN ] [arthome.core.items.dto.ItemDTOMapper] - State ‘OPEN’ is not valid for a group item with base type ‘Number’

Just a warning, but does it appear, because internally openhab ist still collecting the contacts’ states? Can I really ignore it or is there still a problem?

Regards,
Jürgen.

Hmmm… no there must be another reason… the warning comes twice each time I update the file. And there are more elements in the group…

Show your Group definition exactly as you’ve defined it.

This ist the group and all of its elements:

Group:Number:COUNT(“OPEN”) gKontakte “Kontakte (offen) [%d]”

Contact Tuer_EG_Eingang “Tür Erdgeschoss Eingang” (gKontakte) { channel=“homematic:HMIP-SWDO:raspiccu:0000D8A9AA9BC7:1#STATE_CONTACT” }
Contact Fenster_EG_WC “Fenster Erdgeschoss Gäste-WC” (gKontakte) { channel=“homematic:HMIP-SWDO:raspiccu:0000D8A9AA9B5F:1#STATE_CONTACT” }
Contact Tuer_EG_Terrasse “Tür Erdgeschoss Terrasse” (gKontakte) { channel=“homematic:HMIP-SWDO:raspiccu:0000D8A9AA984B:1#STATE_CONTACT” }
Contact Fenster_OG_SZ “Fenster Obergeschoss Schlafzimmer” (gKontakte) { channel=“homematic:HMIP-SWDO:raspiccu:0000DA498D0B8C:1#STATE_CONTACT” }

I remembered that a reboot often helps after a change of a definition… but unfortunately not here…

I’ve never actually used COUNT. I don’t get the same warning using SUM though. It’s a warning, not an error. Does the Group have the correct count or is it remaining NULL or UNDEF?

I use the group in a sitemap and everything works perfect…

Well, since it seems to work you can ignore the warning. You could use SUM instead. I don’t appear to get the warning when I use that. Or you could use the Rule approach from above which will be more involved but avoid the warning.

Other people have recently reported this issue.
Unfortunately, they are reporting it on a three-year-old closed issue.
I think it would be worth creating a new issue for this nuisance warning.

EDIT - created a new issue in openHAB list, instead of smarthome.

I submitted a fix to suppress this warning, but it will be not available until openHAB 3. As it is only a warning and does not block the general feature - I guess - everyone can live with it.

1 Like

FWIW

I’m on 2.5.10 and I’m also seeing the warning in the logs:

2020-10-31 16:22:10.563 [WARN ] [arthome.core.items.dto.ItemDTOMapper] - State 'false' is not valid for a group item with base type 'Number'

Here’s my items definition:

Group:Number:COUNT("true") Shelly_firmware_update (Shelly_Maintenance)

Despite the warning, the group actually provides the correct number :wink:

Bjarne