Make it possible to match on item attribute and it's value - #175
Closed
ohinckel wants to merge 2 commits into
Closed
Make it possible to match on item attribute and it's value#175ohinckel wants to merge 2 commits into
ohinckel wants to merge 2 commits into
Conversation
# e.g. "some.items.*:attr[value]" match items having attribute "attr" with the # value "value"
…es in match_items()
This was referenced Jul 22, 2016
Author
|
Created new PR smarthomeNG/smarthome#80 in new project and will close this issue now. Thanks for your great application! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_itemsetting.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 attributeattrset to valuevalue(new)The value checking supports
attr = somevalue)attr = first | second | third)attr = { first : val1 | second : val2 }(only works with Configure dictionaries in config files #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.