Get list of things bound to the bridge, find a thing and update it

Hi there,

Can you please help me with the following methods (from the BridgeHandler class):

  1. get all things attached to the binding
  2. get these things’ parameters to be able to filter them
  3. update found in step 2 Thing’s channels

My binding receives a message from MQTT and processes it.

I need to find a Thing attached to my binding by a specific type (not really required to get it by type, but can help to not iterate through all things), get a Thing which has ‘myThingId’ parameter set to a specific value and update this Thing’s channel values.

Thank you.

See relevant parts of the documentation below. Specifically, I think you want BaseBridgeHandler.getThing(), Bridge.getThings(), and Thing.getConfiguration(). Note that this gets the list of things that reference the bridge, which may or not be all the things “attached to the binding”.

https://next.openhab.org/javadoc/latest/org/openhab/core/thing/binding/basebridgehandler

https://next.openhab.org/javadoc/latest/org/openhab/core/thing/bridge

https://next.openhab.org/javadoc/latest/org/openhab/core/thing/thing

Thank you.
Exactly what I was looking for.

1 Like