How do I stop things which require a bridge from being manually added?

I’m currently attempting to write a new binding and, having finished a preliminary version, i’ve come across a bit of an issue: My binding uses a bridge which must be manually added (requires a username/password) to communicate with it’s devices, however, when I go to the inbox > add and choose my binding it gives me a list with the bridge and all the devices as well.

Is there a way to only provide the bridge in the manual list? I can see that there is a rest call for item-types that has a listed flag against each one, is it possible to get this set to false somehow?

Can anyone help please?

Thanks

Chris

I would not bother about this, it is common behaviour for e.g. the knx2 binding.
AFAIK you could only prevent this if you do not allow to manually create the depending things in UI, an
example is the KM200 binding, where the bridge is auto discovering its connected things but you can´t
add them manually in the PaperUI.
Nevertheless one could always create a thing in a .things file.

How about making the bridge a mandatory parameter of all your things ?

This can be done by setting listed="false" in thing definition in xml. Like: <thing-type id="electricity_v3_0" listed="false">. Users can still create things in config files (and also have the problem of not having a bridge configured). Even when manually adding a thing the user has to select a bridge (if you added <supported-bridge-type-refs> to your thing definition) So that should give the user already hints that it won’t work without.
I would not know how to make adding a bridge a required parameter.

If the only reason you want to hide them because things need a bridge it is in general not recommended behavior, and will likely be up for discussion in a code review if you would submit the binding to be included in openHAB. The example I gave uses it because there are many things in that binding and depending on the hardware the correct things must be chosen, and it may not clear for the user what to choose. Therefor the things are hidden and auto discovered.

That’s a great help, i’ll give it a try. The devices are discovered through an api and I can’t see any way that a user would be able to get the right ids from the api to add them manually even if they had the bridge setup and selected so I think this would be the right approach in this instance. I’m pretty much ready to submit something to be included.

I migrated all my things to things files, after getting the id from the autodiscovery. So unless your things are not changing the ID, it is quite simple to get the ID.

true.

But that wasn’t what the question was about. You used auto discover to get them. Confirming the point the things don’t need be listed in the UI which was the initial suggested reason to hide it from the list. If the user would have a simple way to get an id through other means it would mean manually adding them via the UI would have added value. It’s not necessarily about if getting the ID is difficult :wink:, but if it’s difficult without auto discovery (which very much depends on the devices(software)).