mknx / smarthome

http://mknx.github.io/smarthome/
GNU General Public License v3.0
126 stars 69 forks source link

Make it possible to match on item attribute and it's value #175

Closed ohinckel closed 7 years ago

ohinckel commented 9 years ago

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

The value checking supports

Something like this is now possible

[somelogic]
  filename = logic.py
  watch_item = *:item_class[light]

[otherlogic]
  filename = logic.py
  watch_item = *:item_class[dimmer]

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.

ohinckel commented 7 years ago

Created new PR smarthomeNG/smarthome#80 in new project and will close this issue now. Thanks for your great application!