The sh.match_items() method is already able to mach items by a given attribute names and return a list of items having the given attribute.
Usually you're using this to identify item having some characteristics. But sometimes you have the same attribute with different values configured and want to handle them differently, for example when connecting them to some logics using watch_item setting.
You can now do
sh.match_items("some.items.*:attr") which returns items with the attribute attr (already working)
sh.match_items("some.items.*:attr[value]") which returns items with the attribute attr set to value value (new)
lists by checking against the list's values (e.g. attr = first | second | third)
dictionary by checking against the dict's keys (e.g. attr = { first : val1 | second : val2 } (only works with #88, of if attributes are set in some code directly)
Further I was also thinking about tree traversal and make it possible to match items using the pattern some.path:attr[value].children.*. But this seems to be more complex and could need a rewrite of the matching logic. And I don't know if this is really a good idea to introduce such a complexity. On the other hand, this feature would be nice, since it makes the configuration more flexible.
The
sh.match_items()
method is already able to mach items by a given attribute names and return a list of items having the given attribute.Usually you're using this to identify item having some characteristics. But sometimes you have the same attribute with different values configured and want to handle them differently, for example when connecting them to some logics using
watch_item
setting.You can now do
sh.match_items("some.items.*:attr")
which returns items with the attributeattr
(already working)sh.match_items("some.items.*:attr[value]")
which returns items with the attributeattr
set to valuevalue
(new)The value checking supports
attr = somevalue
)attr = first | second | third
)attr = { first : val1 | second : val2 }
(only works with #88, of if attributes are set in some code directly)Something like this is now possible
Further I was also thinking about tree traversal and make it possible to match items using the pattern
some.path:attr[value].children.*
. But this seems to be more complex and could need a rewrite of the matching logic. And I don't know if this is really a good idea to introduce such a complexity. On the other hand, this feature would be nice, since it makes the configuration more flexible.