Jython Rule: Member of group / do stuff only if the value of ALL items falls below a specific value

Hi there,

i´m in the process of implementing moisture monitoring. To do this, i put all my moisture sensors (tado) together in a group and created a dummy switch.

As soon as an item rises above 60% humidity, the dummy switch should go to ON - the following script is used for this:

from core.rules import rule
from core.triggers import when

@rule("rule_humidity")
@when("Member of group_humidity changed")

def check_humidity(event):
  humidity = event.itemName
  
  if items[humidity] > 50:
    events.sendCommand("dummy_humidity", "ON")

However, where i have problems is how can i now check whether ALL items in a group have the status of below 60% humidity, because only then should the dummy switch go to OFF.

Of course, i could query each item individually and only switch the dummy switch to OFF as soon as the condition is met, but i think there should also be the possibility of solving this via the group.

Thanks in advance!
Christoph

See Items | openHAB. Use MAX as the Group aggregation function and the state of the Group Item will be the state of the member of the group with the maximum value.

Depending on how you are displaying this and processing this, you might be able to do away with the Rule entirely and just rely on the aggregated state of the Group Item.

1 Like

Thank you very much @rlkoshak, that was exactly what i was looking for and as you suspected, i can now do it without a rule!

- component: oh-list-item
  config:
    title: Humidity
    badge: '=(items.group_humidity.state > 55) ? "HIGH" : "OK"'
    badgeColor: '=(items.group_humidity.state > 55) ? "red" : "green"'
    icon: f7:drop