Hello everyone,
I’m trying to discover Things for my binding using my own implementation of a DiscoveryService
.
The DiscoveryService
picks up the Things correctly and a DiscoveryResult
is sent using thingDiscovered
, inherited from AbstractDiscoveryService
.
The Code responsible for this:
@Component( service = DiscoveryService.class, immediate = true, configurationPid = "discovery.stellwerk")
public class DiscoveryService extends AbstractDiscoveryService {
[...]
private void handleNewIOComponentDiscovered( IIOComponent component )
{
ThingUID uid = ComponentStructureBuilder.getFromThing(component);
Map<String, Object> properties = new HashMap<>();
properties.put(COMPONENT_TYPE, ((component.getType())));
properties.put(COMPONENT_ID, (component.getId()));
properties.put(IS_THING_COMPONENT, "true");
properties.put(COMPONENT_REFERENCE, component);
properties.put(UNIQUE_ID, component.getIdentity());
DiscoveryResultBuilder builder = DiscoveryResultBuilder.create(uid);
builder.withThingType(thingTypeProvider.getFromIOComponent(component));
builder.withLabel("Stellwerk IOComponent - "+component.getIdentity());
builder.withRepresentationProperty(UNIQUE_ID);
builder.withProperties(properties);
DiscoveryResult result = builder.build();
super.thingDiscovered(result);
logger.debug("New IOComponent");
}
[...]
}
Setting a breakpoint after the DiscoveryResult
was created reveals the following structure:
Now, from my understanding of how the Discovery Process works, I would expect for the result to appear in the Inbox.
Unfortunately, this does not happen.
One important thing to note is that I am not using XMLs to define the Things’ structures. Instead, I have implemented a ThingTypeProvider
-OSGi Service and @Reference it inside my ThingHandlerFactory
. The Factory does only get constructed, but not called. This is expected, as the User has not chosen the Thing from the Inbox yet.
Is there something I am missing? Do some of the properties have to have some specific value?
The ThingTypeProvider is annotated as
@Component(service = {StellwerkThingTypeProvider.class, ThingTypeProvider.class})
Could it be that openHAB cannot find the ThingTypeProvider, and because of that, discards the result?
EDIT:
I think I can rule out the
ThingTypeProvider
being the Issue. When I try to add a Thing manually, the Thing Types show up correctly.
EDIT2:
I have followed the code with the debugger and it seems that the
AbstractDiscoveryService
has no listeners attached to it.
This would explain why nothing shows up in the inbox.
Does anyone have an idea as to why this might be happening?