Create own function to update state of Group

  • Platform information:
    • Hardware: Raspberry pi
    • OS: openhabian
    • Java Runtime Environment: 11
    • openHAB version: 3.3.0
  • Issue of the topic:

I have several items for current temperature, humidity and target temperature.
I have the group gThermostat that includes all of the above.

In all UIs, the thermostat group shows with its label and a NULL. I guess that’s the state of the item, which is undef because I didn’t define an item type nor a function. I’d like to define the item-type of group gThermostat as String, and set its state as a sum-up of the children. The children are numbers. The function needs to get the value of each child and format them as a string, like “22C - T 25C - 45%”

In the documentation I see there is only a limited number of functions available. Can we create our own?
Alternatively, I tried creating a rule to update the group state whenever a child is updated. And that kind of works, but the state is reset to undef right away by, I think, the default EQUALITY function. Can I ‘disable’ this function for my group?

rule “gThermostat updater”
when
Member of gThermostat changed
then
gThermostat.postUpdate("")
end

Don’t think there is any way to do any of that. Just use an ordinary String Item.

I’d like to keep using a Group because the UI allows clicking on it to open/show the children

That’s easy to do with a regular Item in sitemap based UI.

Text item=myProxy {
   Text item=member1
   Switch item=member2
}

Clickable ordinary Item.

Should be possible in MainUI with a custom card, but I couldn’t tell you how.

One of the standard MainUI widget actions is to open a specified group popup.

For any page you should be able to use the gui editor to create a label card with whatever item you want as the label and then configure the card to show you the group popup of some different group item.

1 Like

I ended up creating my own list widget, which allowed me to customize the RHS text in the list and even add list-items from different groups. It wasn’t easy though. I wish there were more examples in the documentation. The custom widget system looks really powerful.