New OH2 binding: Tankerkoenig

How did you setup? It looks like the Station is setup via PaperUI. The Web service could have been setup with PaperUI as well, a mixture of UI and file might t be causing problems. I did not test it that way.
When selecting Tankerkoeing binding on the next page you can select either the Webservice or a Station, the page to setup the Webservice should be self explanatory.
If you want to continue with the file use the example in the Read me, put in your key and I’D and it should work.

Hey all,
I cant get my things to become “ONLINE” and both webservice and gas station remain UNKNOWN.

events.log:2017-06-30 14:05:28.244 [hingStatusInfoChangedEvent] - 'tankerkoenig:webservice:69b9b639' changed from UNINITIALIZED to INITIALIZING
events.log:2017-06-30 14:05:28.245 [hingStatusInfoChangedEvent] - 'tankerkoenig:webservice:69b9b639' changed from INITIALIZING to UNKNOWN
events.log:2017-06-30 14:05:28.257 [hingStatusInfoChangedEvent] - 'tankerkoenig:station:3cc3915d' changed from UNINITIALIZED (BRIDGE_UNINITIALIZED) to INITIALIZING
events.log:2017-06-30 14:05:28.264 [hingStatusInfoChangedEvent] - 'tankerkoenig:station:3cc3915d' changed from INITIALIZING to UNKNOWN

I was using http binding successfully before so I doubt its the SSL isssue. Also raised the log level for tankerkoenig & io.net to DEBUG, but no useful hints.
From the 2 gas stations I’m monitoring I just moved one to the binding. The other one is still on HTTP binding and I can see the debug messages for them. But not a single one for the binding one. And tankerkoenig logfile download only shows request from HTTP binding.

Webservice & gas station are setup via PaperUI.

Any ideas how to proceed troubleshooting?
Thanks

How did you do the setup, via file (please post the contents without your API-Key) or via PaperUI?

[Edit]
I missed that you said PaperUI. Sorry. I’m looking into the code now

in which logfile are you looking? It lloks like you’re only looking into events.log, try openhab.log!

Could you also check what the Station item displays in PaperUI, anything more then UNKNOWN?

Hey Jürgen,
thanks for your swift reply. I was log:tail’ing and recursively grep’ing on all OH logs.
PaperUI does not reveal any other info than “Status:UNKNOWN”.
I was wondering as well, that I dont see any tankerkoenig messages at all. Would have expected some initializing debug messages in the logs.

After setting:
log:set DEBUG org.openhab.binding.tankerkoenig.handler
log:set DEBUG org.openhab.binding.tankerkoenig
log:set DEBUG org.eclipse.smarthome.io.net.http

Can I somehow force Tankerkoenig binding start a new connection attempt? Or do I have to wait for the interval?
Thanks

EDIT:
I’m working remotely right now via myopnhab where PaperUI seems to have some problems. When connecting via VPN and accessing PaperUI locally, the gas station sais: "Status: OFFLINE - BRIDGE_OFFLINE"
And the webservice simply sais: “Status: OFFLINE”

log:set DEBUG org.openhab.binding.tankerkoenig
should start the DEBUG log in log:tail, you should see messages like:

15:43:59.100 [DEBUG] [.tankerkoenig.handler.StationHandler] - Update Tankerkoenig data 'tankerkoenig:station:3bc94413'
15:43:59.111 [DEBUG] [.tankerkoenig.handler.StationHandler] - Update Tankerkoenig data 'tankerkoenig:station:fe315531'
15:43:59.124 [DEBUG] [.tankerkoenig.handler.StationHandler] - Update Tankerkoenig data 'tankerkoenig:station:59ad48b1'

These are from a running system, not the start of the binding!

In order to kick off a new interval, do any change on the Webservice (like a different intervall).
In your case I would renew all (delete and build new Webservice and Stations).

When changing Webserver config refresh interval, I can see the changes in debug log

15:47:31.741 [DEBUG] [nkerkoenig.handler.WebserviceHandler] - Refresh job scheduled to run every 30 min. for 'tankerkoenig:webservice:69b9b639'

In fact, the binding must be up and running. Just doesnt attempt to to its query.

That message is just from a Webservice, this job will be done after 30 minutes for the first time. Normally the change to ONLINE should come when initializing a station. The Webservice should go ONLINE at that time as well. A Webservice alone doesn’t send anything!

Thanks for the info. I set the interval to 10mins and suddenly I saw some DEBUG messages in the log confirming a malformed gas-station-id. After correcting a copy&paste error, both (webservice & gas station) become online and are properly reporting prices.
Thanks for you help to get me going.

I’m glad you got it running!

Hi,

I can confirm that it is not working without the webservice part in the items file.

My setup: openhab 2.1 stable on Ubuntu 16.04 with an all text file configuration.

Greetings
Sebastian

1 Like

Thanks and I’m sorry for not finding the time to confirm and change the ReadMe. It’s on my ToDo-List

The changes got merged into the Snapshot version. See the readme in here: `https://github.com/openhab/openhab2-addons/blob/master/addons/binding/org.openhab.binding.tankerkoenig/README.md

Thanks for the inputs @hannibal29, @dolic, @hendrik1287,@cweitkamp

@opus tyvm. Go on with your good work.

The next update is already in its final stages. In order to use the mode opening times correctly, the treatment of holidays needs to be added.
Since my initial version with a complete calculation of all holidays (only those that are valid in all states) wasn’t accepted, I’m going to PR a version with a “holiday” channel ( a channel that reads the state of a switch, which in turn could be set manually, by a rule or by the Caldav bing).

Hello together,

I read the complete thread, but it seems, that I have another problem. I get the following exception:

13:47:37.473 [DEBUG] [ig.internal.data.TankerkoenigService] - Error in getTankerkoenigListResult:
java.io.IOException: java.util.concurrent.ExecutionException: java.nio.channels.ClosedChannelException
at org.eclipse.smarthome.io.net.http.HttpUtil.executeUrlAndGetReponse(HttpUtil.java:255)[113:org.eclipse.smarthome.io.net:0.9.0.b5]
at org.eclipse.smarthome.io.net.http.HttpUtil.executeUrl(HttpUtil.java:149)[113:org.eclipse.smarthome.io.net:0.9.0.b5]
at org.eclipse.smarthome.io.net.http.HttpUtil.executeUrl(HttpUtil.java:122)[113:org.eclipse.smarthome.io.net:0.9.0.b5]
at org.openhab.binding.tankerkoenig.internal.data.TankerkoenigService.getResponseString(TankerkoenigService.java:67)[219:org.openhab.binding.tankerkoenig:2.1.0]
at org.openhab.binding.tankerkoenig.internal.data.TankerkoenigService.getTankerkoenigListResult(TankerkoenigService.java:77)[219:org.openhab.binding.tankerkoenig:2.1.0]
at org.openhab.binding.tankerkoenig.internal.data.TankerkoenigService.getStationListData(TankerkoenigService.java:44)[219:org.openhab.binding.tankerkoenig:2.1.0]
at org.openhab.binding.tankerkoenig.handler.WebserviceHandler.updateStationData(WebserviceHandler.java:137)[219:org.openhab.binding.tankerkoenig:2.1.0]
at org.openhab.binding.tankerkoenig.handler.WebserviceHandler$1.run(WebserviceHandler.java:95)[219:org.openhab.binding.tankerkoenig:2.1.0]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_65]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)[:1.8.0_65]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)[:1.8.0_65]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_65]
at java.lang.Thread.run(Thread.java:745)[:1.8.0_65]
Caused by: java.util.concurrent.ExecutionException: java.nio.channels.ClosedChannelException
at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118)[68:org.eclipse.jetty.client:9.2.19.v20160908]
at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:110)[68:org.eclipse.jetty.client:9.2.19.v20160908]
at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:655)[68:org.eclipse.jetty.client:9.2.19.v20160908]
at org.eclipse.smarthome.io.net.http.HttpUtil.executeUrlAndGetReponse(HttpUtil.java:246)[113:org.eclipse.smarthome.io.net:0.9.0.b5]
… 14 more
Caused by: java.nio.channels.ClosedChannelException
at org.eclipse.jetty.io.WriteFlusher.onClose(WriteFlusher.java:482)[71:org.eclipse.jetty.io:9.2.19.v20160908]
at org.eclipse.jetty.io.AbstractEndPoint.onClose(AbstractEndPoint.java:109)[71:org.eclipse.jetty.io:9.2.19.v20160908]
at org.eclipse.jetty.io.AbstractEndPoint.close(AbstractEndPoint.java:116)[71:org.eclipse.jetty.io:9.2.19.v20160908]
at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.close(SslConnection.java:913)[71:org.eclipse.jetty.io:9.2.19.v20160908]
at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.fill(SslConnection.java:667)[71:org.eclipse.jetty.io:9.2.19.v20160908]
at org.eclipse.jetty.io.ssl.SslConnection$DecryptedEndPoint.flush(SslConnection.java:841)[71:org.eclipse.jetty.io:9.2.19.v20160908]
at org.eclipse.jetty.io.WriteFlusher.flush(WriteFlusher.java:408)[71:org.eclipse.jetty.io:9.2.19.v20160908]
at org.eclipse.jetty.io.WriteFlusher.completeWrite(WriteFlusher.java:364)[71:org.eclipse.jetty.io:9.2.19.v20160908]
at org.eclipse.jetty.io.ssl.SslConnection$1.run(SslConnection.java:98)[71:org.eclipse.jetty.io:9.2.19.v20160908]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)[83:org.eclipse.jetty.util:9.2.19.v20160908]
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)[83:org.eclipse.jetty.util:9.2.19.v20160908]

The API-Key is valid and the station io too. I’ve validated this via a simple https-Call to the prices.php. The certificate, described some posts above, i’ve installed.

Any ideas?

Hi, I’ll look closer into that after the weekend.
From the error posted it has to be something inside the prosecution of the return from Tankerkoenig.de.

Could you raise your debug level for that binding by the following command onto the Karaf console:

log:set DEBUG org.openhab.binding.tankerkoenig

That way we will get a bit more information about the problem.
As an initial guess, what was the return of the posted request onto the browser, a return with only some prices maybe?

The log level you want, is set and the Exception trace is taken with that level.
The return of the request onto browser is a JSON with a list of prices. Note: I take the URI for the request from the log, but I will it not post here, because there is my API-Key inside. The result JSON is:

{“ok”:true,“license”:“CC BY 4.0 - https://creativecommons.tankerkoenig.de”,“data”:“MTS-K”,“prices”:{“51d4b529-a095-1aa0-e100-80009459e03a”:{“status”:“open”,“e5”:1.309,“e10”:1.289,“diesel”:1.119},“51d4b490-a095-1aa0-e100-80009459e03a”:{“status”:“open”,“e5”:1.349,“e10”:1.329,“diesel”:1.159},“d7203f5a-1c7d-41a4-90e1-3ae57e0f760f”:{“status”:“open”,“e5”:1.369,“e10”:1.349,“diesel”:1.179},“13c07bcd-cfe8-4be2-bc32-d518643020d2”:{“status”:“open”,“e5”:1.299,“e10”:1.279,“diesel”:1.109},“b4d96bec-b357-439e-bc21-d0fddd8ef843”:{“status”:“open”,“e5”:1.379,“e10”:false,“diesel”:1.189},“c33fde8d-19f1-4671-bcc7-6e2f27c421c2”:{“status”:“open”,“e5”:1.359,“e10”:1.339,“diesel”:1.169},“8ca6cf1e-a53a-42a2-9d36-9fae63dfca67”:{“status”:“open”,“e5”:1.319,“e10”:1.299,“diesel”:1.129}}}

Other hints:
OH2 running on RaspPi2. Pi have internet access.

Thanks for those inputs. Nothing in the return should be causing this problem.
Is the error coming all the time?
As said before,I’ll have time earliest on a Monday to look into that, if deeper changes would be needed, I would have to postpone that even until to the end of this month, since I’m far from home.

I’m sorry, but reading such posts on a smartphone is asking for error. The reply from Tankerkoenig you got in the browser does have a problem.
One station reports “false” instead of a price for E10, most probably this is causing the problem, leaving out this station at ye moment should resolve the problem until I can come up with a revised code.

What version are you on, since this might have already been solved in athe snapshot version.