searching for where existing rules/scenes/scripts etc are used in openHAB’s UI is very annoying
not very fancy but working I wrote a little bash script to search where rules/scenes/scripts are used in the UI of openHAB (in my case I want to know whether a specified scene/rule is used in other automations, inline scripts or in pages)
basically the script searches your jsondb files(automation_rules.js, uicomponents_ui_pages.json and uicomponents_ui_widget.json) with “jq” (commandline JSON processor)
sudo apt update && sudo apt install jq
just run the script with or without parameter to search for “myRule_or_whatever” and see where it’s used in your UI
please excuse my horrible English
#!/usr/bin/bash
dsh='-----'
[ -z "$1" ] && read -p "search: " s || s="$1"
echo "searching for: '$s'"
f=/var/lib/openhab/jsondb/automation_rules.json
p=/var/lib/openhab/jsondb/uicomponents_ui_page.json
w=/var/lib/openhab/jsondb/uicomponents_ui_widget.json
echo $dsh
echo "results in Rules:"
output=$(echo '{"daten": []}' | jq -r --arg s "$s" 'to_entries[] | select( [.. | strings | select(ascii_downcase | contains($s | ascii_downcase))] | any ) | "Regel-UID: \(.key) | Name: \(.value.value.name)"' $f)
if [[ -z "$output" ]]; then
output=" - no results"
fi
echo "$output"
echo $dsh
echo "results in Pages"
output=$(echo '{"daten": []}' | jq -r --arg s "$s" 'to_entries[] | select( [.. | strings | select(ascii_downcase | contains($s | ascii_downcase))] | any ) | "Page-UID: \(.key) | Name: \(.value.value.name)"' $p)
if [[ -z "$output" ]]; then
output=" - no results"
fi
echo "$output"
echo $dsh
echo "results in widgets"
output=$(echo '{"daten": []}' | jq -r --arg s "$s" 'to_entries[] | select( [.. | strings | select(ascii_downcase | contains($s | ascii_downcase))] | any ) | "Widget-UID: \(.key) | Name: \(.value.value.name)"' $w)
if [[ -z "$output" ]]; then
output=" - no results"
fi
echo "$output"
echo $dsh
just place the script in your home directory, name it “searchoh.sh” or whatever you prefer
remember to make it executable
you can run the script with a parameter (ex: ./searchoh.sh myRule_or_whatever) or without parameter. If no parameter is provided the script asks for by using “read”
the output looks like:
searchoh myRule_or_whatever
searching for: 'myRule_or_whatever'
-----
results in Rules:
Regel-UID: UID_of_myRule_or_whatever | Name: myRule_or_whatever
Regel-UID: c5292abf86 | Name: Rule_which_is_using_myRule_or_whatever
-----
results in Pages
Page-UID: Page_which_is_using_myRule_or_whatever | Name: null
-----
results in widgets
- no results
-----
Can you elaborate on what you find annoying with the UI search, I’m sure the devs would appreciate the feedback and like the chance to further improve it.
I am unfamiliar with the issue you are referencing and (ironically) a quick github search does not result in anything useful. Can you post a link to the issue to help this thread not rehash old issues?
you’re right. the UI’s search functionality is very powerful. In my case I couldn’t find a specific rule used in another rule (not inline script). The above mentioned approach does
thanks for commenting. The above solution is just a suggestion. If you don’t like it or don’t want to use it. It’s on you. If it’s an old or known topic. SORRY. Maybe other users appreciate my suggestion.
Interesting. I guess I’ve never tried to search for a rule referenced in actions and not inline scripts, but you’re right. Even in my recent snapshot, that search condition does not work.
There was a similar issue a while back where item names in rule triggers did not show up in the MainUI search. I think that got resolved, so, it might be worth filing an issue about this specific use-case as well.
Hey, thanks for the great Bash script! Now I can use it instead of my own, and it’s actually working much better.
As someone already mentioned before (although I can’t seem to find the original post anymore), there was an ongoing discussion on GitHub about several issues. However, it was never followed up on and the discussion was simply closed. That’s why I assumed the points had already been addressed and implemented.
Unfortunately, it seems that’s not the case after all.
That’s an interesting point. Administration on mobile has always been less of a priority and the dev sidebar issue is an old limitation with the configuration of the f7 panels in general. The left panel overrides the central space so that still works on smaller screens, but the dev panel shares the space and f7 allows you set a screen width cutoff where that just can’t happen. You see the same effect on the desktop if you just change the size of the browser window. With the dev sidebar open if you start to make the window narrower there will be a point where the dev panel just disappears.
I’d say this is another good viewpoint that is worth a mention as a bug or maybe better a feature request. Shunting some of the dev sidebar features to the Dev Tools menu on smaller screens is quite reasonable.