Showing Empty Batteries in Sitemap [Visibility]

Hi,
I keep getting more and more into openhab and I now started implementing the YAGSA Group approach. It makes a lot of sense, although it is quite a pain in the behind to switch to that standard.

Quite a lot of my Things are Batterydriven and they support a battery status.
I grouped them into

Group fg_gStatus_gBattery "Batteriestatus"

Works great and my Sitemap shows all the Batteries at once if I display the group.
But nobody cares, if the batteries are full, I only want to see the empty ones, so that I know when to replace them. Thus I have a dynamic item in my sitemap:

	Text item=Bathroom_Thermostat_BatteryLevel visibility=[Bathroom_Thermostat_BatteryLevel<15]

Is there any way to do that using my stated group or do I have to do that for each Battery_Status item individually?
I thought of something like this:

Group:Number:MIN    fg_gStatus_gBattery   

But I am puzzled.

Thank you guys

As fas as I know, you have to write down the Widgets individually. Please keep in mind, that the group Widget is a very poor function to get fast results.

Unfortunately, @Udo_Hartmann is correct, you’ll have to add all your items individually in the sitemap

I do a similar thing but approach it by pushing a low battery state message to an email address. It wouldn’t be tricky to adapt this to show the string on the sitemap. Essentially only show it if it’s not ‘NULL’. You could either reset this item state to null with a switch (also only visible when there is a notification) or by a timer. Whatever suits. The rule below should reset the state on the notification item too, but it’s only set to do so at 8am on Saturday when it does the battery level check. You could trigger the rule faster I guess.

An example Sitemap

Text item=vSensor_Bath_Battery visibility=[aBattery != NULL]
Switch item=aNotification_Reset  visibility=[aBattery != NULL]

Copied from my notifications.rules

val String logName = "notification"

////  B A T T E R I E S  ////
/*
The below needs:
Group gSensor_Battery //For all items which are battery values
String aBattery //For notifications
battery.map //For beautifying item names into a readable format.
*/
rule "Low battery alert"
when
    Time cron "0 0 8 ? * SAT" //8am Saturdays
//Filter the group for values below 15%
then
  var triggerDevices = gSensor_Battery.members.filter[ s | s.state <= 15]

//If there is one or more devices that have low batteries then build the notification
  if(triggerDevices.size >= 1) {
    val StringBuilder message = new StringBuilder
    message.append("The following batteries are low: ")
    triggerDevices.forEach[battery | message.append(transform("MAP", "battery.map", battery.name) + " is at " + battery.state.toString + "%, ") ]

//Send the notification
    sendMail("xxxx@gmail.com", "Battery Warning", message.toString) //Email the low battery warning message
    aBattery.postUpdate(message.toString) //Save the message to a string for the dashboard
    logInfo(logName, message.toString)
  }

//Else do not notify
  else {
    aBattery.postUpdate(NULL) //Clear the notification string
  }
end

Add to this rule file something like:

//Reset Battery Alert Notification
rule "Reset Notification"
when
    Item aNotification_Reset changed
then
    if(aBattery.state != NULL) {
       aBattery.postUpdate(NULL) //Only bother resetting the value if it's not already null
       sendCommand(aNotification_Reset, OFF)
    }
end

Apologies if there are errors here, i’m trying to explain this on my break. Let me know if something doesn’t look right.

Another way ist to create dynamicalliy a new group with all empty batteries and show this group. Trigger is then that a memeber of the battery group changes.

I like the Approach but I think I’ll just end up adding the Batteries seperately.

Thanks guys.