Is there a simple way to find all of the Items that have the Google Assistant Metadata set? in jython, I used get_value(Item, metadata) and it works for Custom Metadata but I doesnt seem to work for built-in metadata.
I am trying to find out which Items have “Google Assistant” set to confirm I have the right ones.
There is no reason why Google Assistant metadata would behave any differently from any other metadata. Are you using “ga” as the namespace?
It’s only “built-in” in that the UI is aware of it. But as far as the rest of OH is concerned, including rules, metadata is metadata whether it’s custom or a well-known namespace.
Using the Helper Library get_metadata in Python using list comprehension…
[i for i in items if get_metadata(i, "ga")]
should return a list of the names of the Items that have “ga” metadata.
Note that metadata has three parts: namespace=value[config1=1,config2=2]. Both the value and the config are optional. You are just trying to get the value but the metadata is not guaranteed to have a value perhaps.
Another place to look is the $OH_USERDATA/jsondb/org.openhab.core.items.Metadata.json file. That’s where the actual metadata is stored. You can search by Item name or by namespace to find the record.
But why do you want the actual Item Objects? getValue(), and all the rest of the metadata methods from the Helper Library require the Item names, not the actual Item Object. And you’ve got all the Item names already as the keys to the items dict. So
For the most part, the only time I find myself ever needing an actual Item’s Object is when I want to get the members of a Group or interact with Persistence. To sendCommand, postUpdate, extract Item metadata, get an Item’s state, etc only the name of the Item is needed and in most cases only the name of the Item is supported.