I am working on a Bluetooth based binding where real physical devices can be found based on Bluetooth scans. Each such Thing has a property that identifies its “home”.
In OH architecture the “home” is a Bridge (not an actual physical device, but a logical holder for physical devices), and the actual physical devices are Things within that home Bridge.
So my discovery code needs to find the physical devices and create respective virtual Bridges and actual nested Things in the Inbox.
Is there any other binding that does this already? So I can copy from it. And/or does anyone have thoughts on the discovery code architecture?
I don’t know how similar it is to your setup as I don’t think the sub bridges are discovered, but the modbus binding does have two layers of bridges like you describe.
@rlkoshak it turns out that the structure is even more complex. There is one (or more) physical bridge which is the actual bluetooth stick at the top level. And there are multiple physical things which are devices within range of the physical stick, at the lowest level. And these physical devices may be be grouped into one or more virtual “home” groups / sub bridges, at the middle level. Normally there might only be one mid level “home” per top level stick, but it is possible that there might be more than one “home” per top level stick e.g. “upstairs flat”, “out house” etc.
I don’t know of any binding that can have one Thing be a member of more than one Bridge and I would guess OH wouldn’t allow that.
You might have to handle this sort of thing outside of the whole Bridge hierarchy somehow. Maybe make the grouping through a property on the physical Item’s Thing instead of using a Bridge.
Unless I’m misunderstanding what you are describing.
I now have a Bluetooth USB stick Bridge which hosts several Bluetooth Device Things. And the ThingHandler classes have a public static final Map<Integer, Object> SHARED_DATA_BY_HOME_ID = new ConcurrentHashMap<>(); which is shared (‘static’) across all thing handler class instances, so that each instance can read or write the data that it has in common with other thing handler instances belonging to the same homeId.