use of org.eclipse.smarthome.binding.mqtt.discovery.TopicSubscribe in project smarthome by eclipse.
the class TopicSubscribeMultiConnection method add.
/**
* Add thing if it is a bridge and has a handler that inherits from {@link AbstractBrokerHandler}.
*/
public void add(AbstractBrokerHandler handler) {
final ThingUID bridgeUid = handler.getThing().getUID();
handler.getConnectionAsync().thenAccept(connection -> {
final TopicSubscribe o = new TopicSubscribe(connection, topic, messageReceivedListener, bridgeUid);
observedBrokerHandlers.put(bridgeUid, o);
o.start().exceptionally(e -> {
logger.warn("Failed to MQTT subscribe for {} on topic {}", bridgeUid, topic);
return false;
}).thenRun(() -> {
logger.trace("Found suitable bridge {} for listing to topic {}", bridgeUid, topic);
});
});
}
Aggregations