diff --git a/bin/smarthome.py b/bin/smarthome.py index 7e02a530..b2dd631a 100755 --- a/bin/smarthome.py +++ b/bin/smarthome.py @@ -413,7 +413,11 @@ def match_items(self, regex): regex, __, attr = regex.partition(':') regex = regex.replace('.', '\.').replace('*', '.*') + '$' regex = re.compile(regex) - if attr != '': + attr, __, val = attr.partition('[') + val = val.rstrip(']') + if attr != '' and val != '': + return [self.__item_dict[item] for item in self.__items if regex.match(item) and attr in self.__item_dict[item].conf and ((type(self.__item_dict[item].conf[attr]) in [list,dict] and val in self.__item_dict[item].conf[attr]) or (val == self.__item_dict[item].conf[attr]))] + elif attr != '': return [self.__item_dict[item] for item in self.__items if regex.match(item) and attr in self.__item_dict[item].conf] else: return [self.__item_dict[item] for item in self.__items if regex.match(item)]