New OH2 binding: Tankerkoenig

I don’t think it’s needed to cancel the PR, now that it’s there already. A PR to be open and actively improved is totally normal. Just keep the process clear by commenting from time to time.

Regarding the api load problem: Synchronizing requests sounds like the right approach. You could check other bindings how something like that is done there. Otherwise you could contact developers of similar bindings. A less technical solution would be to simply warn users in the README to not overuse their API key, considering their things count and the configured interval. That would be an okay solution for a first version.

Keep going!!!

Hi all,

thanks to @opus, who supported me a lot with his experience with the tankerkoenig api, I changed a bit the binding handling in order to save some superfluous api requests.

Additionally I added the with a little description how to set up the binding.

If someone is curious and wants to test the binding, you can download the binding here:
I’d recommend to set it up in a development environment, since there will be a few bugs for sure. One known issue I’m already working on is, that the binding seems to update values only after a restart :frowning:

Nevertheless, I would appreciate to get it tested :slight_smile:

Besides the need to restart before any data is fetched from I have observed no errors over the day of testing ( using 3 fuel-stations).
Thanks for this binding.

Did check how often the prices were fetched, I can’t see the 10 minutes I did set at all!
I do see steps between 1 and 10 minutes!
I’ll stop the binding for now.

I have made a “sidestep” and created a rule that does what I intend to do with the binding regarding opening times. That is working! Posted here
Now I’m trying to get the same working in Eclipse with the binding. I do have problems using either the feature the author used (make another polling job, use the *service to get data). But I’ll get there, but it will take some more time.

It seems to me that I’m at a dead end street in trying to adjust the binding using Eclipse.
Could anybody try to help? Or should I ask on github?

I used the code build by @dolic and added additional code which mimics the already used classes and methods “TankerkoenigListXXX” and added “TankerkoenigDetailXXX” (including all needed sub-types). The difference between both is that the later uses the “detail.php” to get detail data.
For using them I also created a “TankerkoenigDetailService” with the “GetTankerkoenigDetailResult” method.
When trying to call it inside a response job using this code:"UpdateTankstellenDetails jsonData : {}", jsonData);
    GsonBuilder gsonBuilder = new GsonBuilder();
            new CustomTankerkoenigDetailResultDeserializer());
    Gson gson = gsonBuilder.create();"UpdateTankstellenDetails before creating res");
    TankerkoenigDetailResult res = gson.fromJson(jsonData, TankerkoenigDetailResult.class);"UpdateTankstellenDetails res : {}", res); 

I get correct log-entries for the jsonData (I verfied the reported string) and as a last entry “UpdateTankstellenDetails before creating res”. After that I get no more entries.

The problem is my " CustomTankerkoenigDetailResultDeserializer", but I’m unable to solve that one.


i dont get the binding running. The itemvalues just show NULL an i got this in my logs:

18:09:47.696 [ERROR] [ome.core.thing.internal.ThingManager] - Exception occurred while initializing handler of thing 'tankerkoenig:config:a174bea6': java.lang.NullPointerException
java.util.concurrent.ExecutionException: java.lang.NullPointerException
        at java.util.concurrent.FutureTask.get([:1.8.0_131]
        at org.eclipse.smarthome.core.common.SafeMethodCaller.callAsynchronous([99:org.eclipse.smarthome.core:]
        at org.eclipse.smarthome.core.thing.internal.ThingManager$[106:org.eclipse.smarthome.core.thing:]
        at java.util.concurrent.Executors$[:1.8.0_131]
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201([:1.8.0_131]
        at java.util.concurrent.ScheduledThreadPoolExecutor$[:1.8.0_131]
        at java.util.concurrent.ThreadPoolExecutor.runWorker([:1.8.0_131]
        at java.util.concurrent.ThreadPoolExecutor$[:1.8.0_131]
Caused by: java.lang.NullPointerException
        at org.openhab.binding.tankerkoenig.handler.BridgeHandler.initialize([237:org.openhab.binding.tankerkoenig:]
        at org.eclipse.smarthome.core.thing.internal.ThingManager$9$[106:org.eclipse.smarthome.core.thing:]
        at org.eclipse.smarthome.core.thing.internal.ThingManager$9$[106:org.eclipse.smarthome.core.thing:]
        at org.eclipse.smarthome.core.common.SafeMethodCaller$[99:org.eclipse.smarthome.core:]
        ... 3 more

Could you give some details on your setup?
Where did you get the binding from? Since the pull request isn’t approved yet, the most actual.jar can be downloaded on the eclipse marketplace (last one from yesterday)
How did you setup your system? Did you create a bridge with your personal Api key?
Did you create any 'Tankstelle" with the respective ID?
Are you using openHAB2? This binding is made for that version!
Link to the Marketplace


i installed it with the paperui… there it appears as a marketplace-binding, i am using openhab2, snapshot of last week.

on the homepage i created a api-key, then i added the configuration as a thing with the api-key, then i added three tankstellen as things with their ids. of course i choose the configuration-thing as bridge (was the only value i could choose).
then i created a linked item for one of the tankstellen.

all the created things have the status “UNINITIALIZED - HANDLER_INITIALIZING_ERROR” in the paperui things overview

thanks for your help!

It looks like you are doing everything correct!
You are on a snapshot release which I’m not, however that should not explain that error.
Can you give me your exact binding version ( from the karaf console use bundle:list). That way I could pinpoint where the error is coming from, or if it might be resolved already (don’t think so)
I not at home, so actual help by changing code does have to wait until the end of the weekend, I’m sorry.

ok, here is the binding version. i will try to update to the latest snapshot, if this solves the problem, i give you an update here.


237 | Active | 80 | | Tankerkoenig Binding

Thanks, although that was stupid question of me, since that is reported in the error you posted already.
You are using the version of last night, so the is nothing newer!

I’m not sure ,but thisLink the my Dropbox might give you on older version, that was reported working.
Will look into the one on the marketplace when I ’ m back.

thank you - i am going to try this out.

updating to the latest snapshot #935 didnt help

the older version doenst work for me, i cant add any things as you can see on the screenshot:

That should work under Configuration -Things, clicking on the plus sign should show the dialog from which binding to add things…
Let me know if that doesn’t work either.

with the binding from the market it works this may, with the older version it didnt.

In this case you have to wait until I’m back home. I already have an idea what causes the error, but I need to check.
I’ll write in here if I have something new. Is that OK with you?

Of course! I am very thankful for your help and Support!