I’ve migrated to Openhab 3 and now see a lot of invalid links in the Items dashboard.
I want to delete all those invalid links.
If I click on a unitary invalid link, I can do it. But it would take hours to click every link on every item.
Is there a command to clean all the invalid links programatically ?
The REST API is designed to permit doing things programmatically.
Thank you Bruce ! As nearly everything in computer science
But to go beyond, I was just wondering if something more directly accessible was existing, like a documentation entry pointing out a button “cleanup” or an automatic cleaning algorithm as a service ?
There is no automatic cleanup service in OH. You’ll have to “manually” remove the erroneous links. Given the REST API that would be scriptable. Or you can open the JSONDB file and manually remove them.
There are times where one may have temporarily removed the Item or temporarily removed the Thing but you do not want to remove the Link. If the Link were removed automatically, for example, you’d have to recreate all of your Links every time you reload a .items file if the links are defined through the UI. So OH takes a bit of a hands off when it comes to cleaning up the links because ultimately, it doesn’t have enough information to tell the difference between a temporarily invalid Link and one that needs to be removed.
Uninstalling the zwave binding to manually install a snapshot version is another time you would not want links to disappear.
Yep, I agree ! Thank you for your insights.
I am very surprised by the quantity of invalid links (that I do not want to keep) accumulated from my first installation of openhab2 two years ago. I will go and delete them manually
You probably had Simple Mode turned on. I’m so glad simple mode is gone.
Would the following console command work? It “purges all orphaned - one missing element (either item or channel) - links”
openhab:links orphan purge
It did remove the links, but not the items associated with the links.
Thank you for this @amosk !
I just upgraded from OH 3.1 to 3.3 and had to recreate all my MQTT Homeassistant esphome Things, resulting in invalid links all over the place.
I was searching the forums for a way to list all Item invalid links in bulk, at once, so I’m sure I’m reconnecting everything.
With your tip and using help I found the command below in openhab-cli console, which is what I needed:
openhab:links orphan list
Side note: boy did I have a lot of oooold invalid links in there