Cannot create thing. No binding found that supports creating a thing of type

Tags: #<Tag:0x00007f434a2b5568> #<Tag:0x00007f434a2b5108> #<Tag:0x00007f434a2b4e60>

Hello,
I am new in development bindings for openHab. I was able to set up the development environment (at least I hope so). I started creating my first binding. I read the documentation but I am not able to find the problem.

I receive the error message:

 "Cannot create thing. No binding found that supports creating a thing of type 'haassohnpelletoven:oven'."

This is my binding.xml:

<?xml version="1.0" encoding="UTF-8"?>
<binding:binding id="haassohnpelletoven" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">

<name>Haas and Sohn Pelletoven Binding</name>
<description>The binding for haassohnpelletoven communicates with a Haas and Sohn Pelletoven through the optional WLAN-Modul. More information can be found here: https://www.haassohn.com/de/ihr-plus/WLAN-Funktion</description>

 </binding:binding>

Then my Handler:

@NonNullByDefault
public class haassohnpelletovenHandler extends BaseThingHandler {

private final Logger logger = LoggerFactory.getLogger(haassohnpelletovenHandler.class);

private final String hostIP;
private final String hostPIN;
private final Gson gson;
private @Nullable ScheduledFuture<?> refreshJob;

private static final int DEFAULT_REFRESH_PERIOD = 20; // Refresh of 20 seconds

private @Nullable haassohnpelletovenConfiguration config;
private @Nullable OvenJsonData ovenData;
boolean resultOk = false;

    @Activate
    public haassohnpelletovenHandler(Thing thing, String hostIP, String hostPIN) {
    super(thing);
    this.hostIP = hostIP;
    this.hostPIN = hostPIN;
    gson = new Gson();
}

and my factory:

@NonNullByDefault
@Component(configurationPid = "binding.haassohnpelletoven", service = ThingHandlerFactory.class)
public class haassohnpelletovenHandlerFactory extends BaseThingHandlerFactory {

private final String hostIP;
private final String hostPIN;

private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_OVEN);

public haassohnpelletovenHandlerFactory(final String hostIP, final String hostPIN) {
    this.hostIP = hostIP;
    this.hostPIN = hostPIN;
}

and my constants:

public class haassohnpelletovenBindingConstants {

private static final String BINDING_ID = "haassohnpelletoven";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_OVEN = new ThingTypeUID(BINDING_ID, "oven");

// List of all Channel ids
public static final String CHANNEL_1 = "channel1";

}

Can anyone give me a hint, what I am doing wrong?

There are a number of problems. The least is you should use proper naming conventions for Java classes. But this is due to how you created the binding with the script.

Related to your problem. The factory class should create an instance of the handler. An example is in the binding created by the script. But this is missing from the code above.

You also pass variables to the constructor of the factory. These look like thing configuration parameters. And thus I would expect those to be read in the handler initialize. Check what the example isn the by the script generated example is done.

If possible and you want more feedback please post your code on GitHub so it’s easier to point to specific lines of code.

1 Like

Hello hilbrand,

thanks for taking the time. I am aware of the naming conventions for Java but made a mistake when I used the script. I will refactor it, as soon as I get it running.

I do have a an instance of the handler. I just did not post it as I used the one from the script.

However I followed your suggestion and uploaded my code to my github:

Maybe you can have a look and let me know where exactly my problem is. As said I am new to the openHab community. I already developed the code which I need for the binding to connect the oven, I just haven’t mastered the openHab frameworkt yet.

Any help is highly appreciated.

Regards
Christian

I found the problem and fixed it myself. Thanks for help

2 Likes

Hello,

I have to pick that up again. I looked in the source code of many other bindings and I saw that a lot of developers are using a constructor in the Factory for example in the AstroHandlerFactory:

   @Activate
public AstroHandlerFactory(final @Reference CronScheduler scheduler,
        final @Reference TimeZoneProvider timeZoneProvider) {
    this.scheduler = scheduler;
    this.timeZoneProvider = timeZoneProvider;
}

Can somebody explain me, what is the purpose of this approach and what else need to be configured in order that it works? When I use in my code I always get the error that no binding could be found as indicated above and it does not jump into the FactoryHandler.

When I first started I thought that would be the way to receive the User Data entered by a User on the WebUI when you create a Thing, but this data is part of the Thing Properties.

So please forgive me, if the solution is so obvious, for me its not as it is my first days with an openHab binding.

The @Active is a way instruct the OSGI framework it should use that constructor to start the service. The @Reference indicates the class is another service that needs to be injected into the constructor. A service is another class that is also annotated with @Component. These classes are created by the OSGI framework. (All these annotations are part of OSGI).

So to get a class passed here via the @Reference it needs to be annotated by @Component. You can see such a class as a singleton. In general classes used as services are classes that run by them selves and are not created by other classes (in your binding). And in general you probably don’t need those in your binding.

1 Like

Thanks for explanation. I am almost done with my Binding. Most of it already works. I am able to handle a Switch to turn on/off the oven and I receive the actual Temperature.

I have some remaining questions I was not able to figure in the documentation.

  1. After I created a Thing which is binded, maybe I get an error due to wrong input of the config in the WebUI. If I edit then the config file in the openHab WebUI what gets called in order to update the config data? At the moment the newly entered Data is not considered.

  2. If I link an Item to a channel. Where do I have to specify in my code or in the config files what is the only valid type of the to be linked item as well as the Semantic class and property?

  3. I do have one channel where I have to link a set temperature. I was able to link it to the type Number:Temperature. But how do I make it editable, so that the user is able to enter a target temperature? At the moment its just displaying the actual set temperature.

I would appreciate if someone could answer this questions to me in order to finalize my first binding.

Thanks

Ja, es funktioniert schon. Ich kann dir vorab das JAR zukommen lassen.

Nicht schwierig. Kopiere die JAR-Datei einfach ins Addon-VZ von openhab, dann wird es automatisch erkannt. Probiere es mal aus wenn du magst. Du kannst eine Vorabversion hier runterladen. Geht ab openhab 3.0.
Aktuell fehlen noch ein paar Schönheitskorrekturen und Code Reviews, dann wird das Plugin offiziell zu released aber die Funktionalität ist aktuell schon komplett.

Lass mich wissen ob es funktioniert und wenn welches Ofenmodell du hast, dann kann ich das Modell offiziell als getestet aufnehmen wenn es denn funktioniert.

Das Thing dann am besten ĂĽber die openhab Webinterface anlegen, damit geht es aktuell noch am besten.

Sorry guys, english please, this is an international community.

Was my last message not understandable?
Please post in english !

Fine for me. I just saw the email and thought it was a private message. Don’t worry, keep replying in English

is it possible to take part in a test here? i am also looking for a Haas and Son Binding. unfortunately I’m still brand new with OpenHAB

Hello,
I think it is going to be merged to main soon. So far you can use the trial version as described above.