Visualize group status of several string status items (ok, warning, error)

  • Platform information:
    • Hardware: RPI 3B+
    • OS: latest openhabian image / Linux 9 stretch
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: openHAB 2.4.0-1 (Release Build)

I read out several status strings from a website like “ok, warning, error” which are in one group. For this group I want to have a color indicator light, so I need to know the group status itself.

Group	ServiceStatus	"service status [%s]"
String 	ServiceStatus1	"service status 1 [%s]"	(ServiceStatus)	{http="<[ServiceStatus:600000:REGEX(.*?}
String 	ServiceStatus2	"service status 2 [%s]"	(ServiceStatus)	{http="<[ServiceStatus:600000:REGEX(.*?}

Group state in this case is always null. :frowning:
If there would be just two states I would be able to “map” e.g. ok and error to ON/OFF to virtual switch items, group (with Group:Switch:OR(ON,OFF) m ) them and control the light according .
But with this three states I have no good and easy idea how to achieve this.

My idea is to create a rule for each group, which is triggered on every item change and then check inside the rule if either at least one item is error (then light becomes red) or warning (then set light to orange) otherwise set the light to green.

Or can I map the string state I get from the HTTP binding to a numeric value like 1=ok, 2=warning and 3=error and then it would be possible to check the group state with “Group:Number:MAX”?

Yes. You have no (sub) type or aggregation function specified in the Group definition, which is the only way to get a Group state.

The underlying difficulty is that although you can use rules to prioritise alerts etc. you’ve no way to force a Group state.

I think I would create a single ordinary Item to represent the “Group” condition.
By all means have all your member Items in a Group, and trigger a rule from Member of to do the updating of that Item.
But you’ll have the flexibility to handle your own priorities and exceptions in your rule code.

There’s more than one way to do it of course, what suits best may depend on future plans etc.