This is a generic question, hence, no further detail about the specific hardware/software config.
I am trying to:
extract all item names from the org.openhab.core.items.Item.json file. Solved:jq -r 'keys[]' org.openhab.core.items.Item.json
ideally get a list of item names and their state
What I am really interested in, is more specific: find all items with state = UNDEF.
However, listing items names is generically useful for me; so is any state. I should be able to apply relevant filters.
I tried jq, but could not make it work, as the first property name is the item, not the property value.
This often leads to XY Problems as questions like this exclude other possiblities which might be a better approach over all.
As @Oliver2 indicates, you’ll only be able to get access to the Item’s states through the REST API. But once you have that you’ll be able to use jq to parse out what you need.
You could also do this in a quick rule if all you are after are the names of the UNDEF Items. In JS it would be:
items.filter( i => i.state == "UNDEF" ).forEach( i => console.log(i.name + " is UNDEF") );
In Rules DSL it would be something like:
org.eclipse.smarthome.model.script.ScriptServiceUtil.getItemRegistry().getItems().filter[ i | i.state == UNDEF].forEach[ i | logInfo('UNDEF Items', i.name + ' is UNDEF') ]
Oh, and I forgot to mention that the Developer Sidebar can search Item states. So searching for NULL there will show all the Items that are NULL.