HABApp 0.31.0

Good news everyone!

I just released HABApp 0.31.0!

This release brings lots of improvements the most notably full support for tags and groups and an easy option to search for items.

Item search

# This seaches for items that are in group 'my_group' and have the tags set
for item in self.get_items(groups='my_group', tags=['tag1', 'tag2']):
    print(item.tags)      # All tags are now on the OpenhabItem
    print(item.groups)    # All defined groups are accessable, too
# This returns all switch items
for item in self.get_items(type=SwitchItem):
# This returns all items who's name end with _battery
for item in self.get_items(name='_battery'):

Groups and Tags

group = GroupItem.get_item('My_Group')

# It's possible to get the defined children of a group directly
for item in group.members:

# Items have the definition as a property

That sounds great. Then it should be possible tp create rules based on groups.

Did it get it right that this should work

for sensor in GroupItem.get_item('gCOL_PlantSensors').members:

Yes and sensor is the corresponding item, not the name of the item.
So HABApp does the item lookup for you.

As always - I recommend using a good naming scheme over groups because it’s much more flexible (e.g. Plant_Name_Sensor) and it allows changes in logic without having to edit the item definitions.

Another even better option is to pass the item names directly to the rule class

class MyRule(HABApp.Rule):
    def __init__(self, item1: str, item2: str):
        self.switch = SwitchItem.get_item(item1)
        self.sensor = NumberItem.get_item(item2)

MyRule('my_item1', 'my_next_item1')
MyRule('my_item2', 'my_next_item2')
MyRule('my_item3', 'my_next_item3')

That way you get error messages if an item is missing and/or has not the correct type.