[Solved] Find any item with value of NULL

Is there a way I can iterate through every item and check for NULL values? I have an item I cant find that im getting an error in my log but would be good to go through each and every item

Use the REST API and then search the results?

http://[your_server]/rest/items?recursive=false

EDIT: I guess that is the wrong URL to get status.
It looks like you would need to iterate through all your items.

http://[your_server]/rest/items/{itemname}/state

http://[ip address of openhab server]:8080/rest/items?recursive=false
spits out a json of every item

1 Like

True but the state is per item like I listed above.

If you’re running Linux and you have jq installed…

curl --silent -X GET --header "Accept: application/json" http://your.host:8080/rest/items?recursive=false | jq -r '.[] | "\(.name) \(.state)"' | grep NULL

Should produce output that looks like this.

WU_F3_ObservationTime NULL
TTS_Message NULL
RSCAA66_Z5_BassProxy NULL
RSCAA66_Z5_BalanceProxy NULL
WU_F9_WeatherIcon NULL

Edit: Which reminds me I need to get rid of those unused WeatherUnderground items…

1 Like

Thanks @mhilbush that works a treat - i am assuming group items are always null if they dont have a type? (how could I exclude these with jq?)

Hmm. Good question. That’s a little beyond my jq skills. :frowning:

I know you can filter the REST query on type. Like this:

curl --silent -X GET --header "Accept: application/json" 'http://your.host:8080/rest/items?recursive=false&type=Group' | jq -r '.[] | "\(.name) \(.state)"' | grep NULL

But I don’t know how to do a “not type=Group”.

Try this. :wink:

curl --silent -X GET --header "Accept: application/json" 'http://your.host:8080/rest/items?recursive=false' | jq -r '.[] | select(.type != "Group") | "\(.name) \(.state)"'
1 Like

Perfect