Need help with MIN Aggregation

Running OH 5.1.1 on RPi 5 configured entirely with Main UI

Created a number Group whose members are Battery Levels of my 5 Smoke Detectors.

I was hoping to create an alert when any Detector Battery level drops below a defined level.

The Group value always shows as Undefined but I expected a Number value

The Group yaml is

version: 1
items:
gSmokeDetectorBatteries:
type: Group
group:
type: Number
dimension: Dimensionless
function: Min
label: gSmoke Detector Batteries
unit: ‘%’
tags:

  • Level
  • Measurement
    metadata:
    stateDescription:
    value: ’ ’

I’ve studied the docs but without finding a solution.

Any help is appreciated.

Update: Revised the Group to remove the Dimension and it’s working.

Did you recently create the group item?
The group item does not look up the group member’s item states to set the initial state once it is created. The group state is updated once a member item gets updated. This can take a while if items are battery-driven, especially smoke detectors have long communication cycles.

While this is kind of legible, quotes is no the same as code fences. Please use code fences for configs. In YAML in particular, the indentation is meaningful.

```
code goes here
```

This should work with units so I wonder if @Oliver2’s idea is what happened. Battery levels in particular are slow to update usually.

Finally, I’ll point out that there is a way to achieve this with stuff from the marketplace.

Install Threshold Alert and Open Reminder [4.0.0.0;5.9.9.9].

Create a rule to send your alert message (anything but Rules DSL). It will have access to the following information when it’s called:

Variable Purpose
alertItem name of the Item that generated the alert
alertState current state of the Item
isAlerting boolean, when true the Item meets the threshold comparison, when false the Item exited the threshold state
isInitialAlert boolean, when true the Item just now met the threshold comparison, when `false, the Item has been in this state for awhile.
threshItems JavaScript Array of JavaScript Item Objects whose state meet the alerting criteria
threshItemLabels JavaScript Array of the Item labels whose state meet the alerting criteria
nullItems JavaScript Array of JavaScript Item Objects whose state is NULL or UNDEF
nullItemLabels JavaScript Array of the Item labels whose state is NULL or UNDEF

This is what my battery alerting rule is:

const refid = items[alertItem].name+'_low_battery_alert';

if(isAlerting) {
  const msg = items[alertItem].label + ' is low at ' + alertState + '! Time to replace.';;
  console.info(msg);
  actions.notificationBuilder(msg)
         .addUserId('me@email.com')
         .withTag('Alert')
         .withTitle(items[alertItem].label + ' Low!')
         .withIcon('f7:battery_0')
         .withReferenceId(refid)                              
         .send();    
}
else {
  console.info(items[alertItem].name + ' is no longer low.');
  actions.notificationBuilder("hide notification").withReferenceId(refid).hide().send();
}

This uses the built in notifications of OH. When the battery is no longer low, the alert gets canceled.

Create a new rule with Threshold Alert as the template with the following configuration (leave unlisted properties at their defaults):

Property Value Notes
Triggering Group gSmokeDetectorBatteries
Threshold State 10% or what ever minimum percent you want to use to get the alert.
Comparison Operator < or <=
Alert Delay PT15M Battery needs to be below the threshold for 15 minutes before alerting
Reminder Period PT12H The alert will be made every 12 hours until the battery is no longer too low
Rule select the rule you created above I appear to have a bug in my properties, these should be labeled with more than just “Rule”, this is the rule that is called when the Item meets the threshold for at least Alert Delay time
Rule select the rule created above, optional This is the endAlert rule and gets called when the Item is no longer in the alerting state
Rule leave blank This is the rule that gets called immediately when the Item enters the alerting state.

If you don’t want these alerts at certain times of day (e.g. over night) set the Do Not Disturb start and end times for the time period you do not want to receive alerts. Alerts that occur during that DND period will be saved and sent at the end of the time period so you will not miss an alert nor a reminder.

Adjust the values above as necessary.

To visualize your battery on MainUI there’s: