[solved] Tankerkoenig - Price "drops" to 0,00 EUR

Hi all,

after a Hardware failure last week I updated my openhab 1.8 Installation to actual openHab2.
After some struggling with the new Environment (Paper UI) I have most things working again.

One Problem I have: I used the tankerkoenig API to get prices of the 3 nearest petrol stations. The prices were also drawn in a rrd graph to see the daily “flow”. The Price reading in openhab1 was done via http-binding.

Within openhab2 I installed the tankerkoenig binding and configured everything. I get the price of my three stations and everything is fine - except when a station closes the price item is updated to 0,00 EUR. This problem occurs with 2 of the stations while the other station reports the last price. This would be my prefered variant for all three stations…

I also tried to work with the “opening” switch to get only price updates when the station is open but it did not work.

Can someone point me to the right settings?

Thank you in advance,
Andreas

Better tell us that gas station’s whereabouts!
SCNR

The drop to 0€ if the station closes is a feature. Works as designed

@mstormi don’t have to come around - station is closed for sure :wink:
Opening times are correct…

@Dibbler42 : what a pitty… the chart looks a bit ugly if it drops to 0 in night time… and ypu can’t really see the changes over the day (10 cent span vs. 1,30 EUR drop…)
In my opinion it would make more sense to leave the value om last value (because price does not drop) and have a second channel/item (switch) for open/closed for every station…

Andreas

On the other hand you are not able to see if the station is closed.

Thomas

There are two ways to skin that cat!
A:
Use the mode OpeningTimes, in this mode the binding uses the reported opening times in order not the poll an actually closed station. That way the price of a closed station will get no update, so the last price will be used during closing times.
For the correct usage the binding does need the information if the actual day is a holiday.(I’m using that)
B.
Use proxy items and make a rule that only does update the item if the Open channel is true.

Actually, the rules as posted by Tankerkönig (and they are acting on the rules of M-TSK) are, that NO price should be published if the station is closed. By providing a binding for this service, this rule has to be obeyed (at least in my opinion).
Since I’m using the binding with a rrd4j persistence as well,I know the problem and it is solveable.

I would expect that behaviour by All station that close sometime. Are you sure this last station does close? However it is known that the actual reporting of each station isn’t in line with rules anyhow.

Not in a position to test of offer an actual solution at the moment, however, a quick variation on Jürgen idea I thought I would post could be instead of a rule watching the open channel, you could try a rule that only updates the price if the new price is greater than 0.00.

If you can play with the code that displays the graph you could also try reworking the algorithm to either not include 0.00 values, or to change all 0.00 values (in terms of for display not for database) to the previously reported value.

Not a solution I know but hopefully an idea someone can run with.

Thank you for all your Input.
I set logging for tankerkoenig binding to DEBUG and have found the error, why one station still have a price overnight although the station is closed in real world: the two stations return opening times in the detailed station data, but the single one has no opening times defined…

2017-10-18 17:18:11.558 [DEBUG] [.tankerkoenig.handler.StationHandler] - Try to refresh detail data
2017-10-18 17:18:11.718 [DEBUG] [ig.internal.data.TankerkoenigService] - getTankerkoenigDetailResult jsonData : {"ok":true,"license":"CC BY 4.0 -  https:\/\/creativecommons.tankerkoenig.de","data":"MTS-K","status":"ok","station":{"id":"42d6d4cc-6909-45fc-f60f-a1abd9ea1f0e","name":"CleanCar AG","brand":"CleanCar AG","street":"Lembergallee","houseNumber":"1","postCode":79108,"place":"Freiburg","openingTimes":[{"text":"Mo-Fr","start":"06:00:00","end":"22:00:00"},{"text":"Samstag","start":"07:00:00","end":"20:00:00"},{"text":"Sonntag, Feiertag","start":"09:00:00","end":"17:00:00"}],"overrides":[],"wholeDay":false,"isOpen":true,"e5":1.299,"e10":1.279,"diesel":1.109,"lat":48.0321,"lng":7.84501,"state":"deBW"}}
2017-10-18 17:18:11.723 [DEBUG] [.tankerkoenig.handler.StationHandler] - Update Tankerkoenig data 'tankerkoenig:station:WebserviceName:StationName2'
2017-10-18 17:18:11.744 [DEBUG] [.tankerkoenig.handler.StationHandler] - updateDetailData openingTimes: org.openhab.binding.tankerkoenig.internal.config.OpeningTimes@1b24e1a
2017-10-18 17:18:11.749 [DEBUG] [.tankerkoenig.handler.StationHandler] - Try to refresh detail data
2017-10-18 17:18:11.749 [DEBUG] [.tankerkoenig.handler.StationHandler] - Try to refresh detail data
2017-10-18 17:18:11.800 [DEBUG] [ig.internal.data.TankerkoenigService] - getTankerkoenigDetailResult jsonData : {"ok":true,"license":"CC BY 4.0 -  https:\/\/creativecommons.tankerkoenig.de","data":"MTS-K","status":"ok","station":{"id":"3e9014fa-cd68-41b7-9382-376dbb8bba5f","name":"Esso Tankstelle","brand":"ESSO","street":"SUNDGAUALLEE 25 SUED","houseNumber":" ","postCode":79114,"place":"FREIBURG","openingTimes":[],"overrides":[],"wholeDay":true,"isOpen":true,"e5":1.299,"e10":1.279,"diesel":1.139,"lat":48.010207,"lng":7.812219,"state":null}}
2017-10-18 17:18:11.804 [DEBUG] [.tankerkoenig.handler.StationHandler] - Update Tankerkoenig data 'tankerkoenig:station:WebserviceName:StationName1'
2017-10-18 17:18:11.820 [DEBUG] [.tankerkoenig.handler.StationHandler] - updateDetailData openingTimes: org.openhab.binding.tankerkoenig.internal.config.OpeningTimes@14a256a
2017-10-18 17:18:11.842 [DEBUG] [ig.internal.data.TankerkoenigService] - getTankerkoenigDetailResult jsonData : {"ok":true,"license":"CC BY 4.0 -  https:\/\/creativecommons.tankerkoenig.de","data":"MTS-K","status":"ok","station":{"id":"cd8ba6a6-9577-1ee5-a181-12e717e9041d","name":"JET FREIBURG INGEBORG-KRUMMER-SCHROTH-STR. 33","brand":"JET","street":"INGEBORG-KRUMMER-SCHROTH-STR. 33","houseNumber":null,"postCode":79106,"place":"FREIBURG","openingTimes":[{"text":"t\u00e4glich ausser Sonn- und Feiertagen","start":"06:00:00","end":"22:00:00"},{"text":"Sonntag, Feiertag","start":"07:00:00","end":"22:00:00"}],"overrides":[],"wholeDay":false,"isOpen":true,"e5":1.289,"e10":1.269,"diesel":1.129,"lat":48.015806,"lng":7.850389,"state":null}}
2017-10-18 17:18:11.850 [DEBUG] [.tankerkoenig.handler.StationHandler] - Update Tankerkoenig data 'tankerkoenig:station:WebserviceName:StationName3'
2017-10-18 17:18:11.869 [DEBUG] [.tankerkoenig.handler.StationHandler] - updateDetailData openingTimes: org.openhab.binding.tankerkoenig.internal.config.OpeningTimes@14eda72

The log for the price update looks like this, when stations are closed (but one is said to be open):

2017-10-19 03:29:22.999 [DEBUG] [.tankerkoenig.handler.StationHandler] - Update Tankerkoenig data 'tankerkoenig:station:WebserviceName:StationName1'
2017-10-19 03:29:23.013 [DEBUG] [.tankerkoenig.handler.StationHandler] - Update Tankerkoenig data 'tankerkoenig:station:WebserviceName:StationName2'
2017-10-19 03:29:23.023 [DEBUG] [.tankerkoenig.handler.StationHandler] - Update Tankerkoenig data 'tankerkoenig:station:WebserviceName:StationName3'
2017-10-19 03:39:23.191 [DEBUG] [ig.internal.data.TankerkoenigService] - json-String: {"ok":true,"license":"CC BY 4.0 -  https:\/\/creativecommons.tankerkoenig.de","data":"MTS-K","prices":{"3e9014fa-cd68-41b7-9382-376dbb8bba5f":{"status":"open","e5":1.379,"e10":1.359,"diesel":1.219},"42d6d4cc-6909-45fc-f60f-a1abd9ea1f0e":{"status":"closed"},"cd8ba6a6-9577-1ee5-a181-12e717e9041d":{"status":"closed"}}}

I think everything is fine and clear at the moment and I can understand the behavior.

If I try to set the switch “Opening times” within the configuration of the tankerkoenig web service and save the Settings, an error occured and the logs say this:

2017-10-19 05:56:11.196 [INFO ] [ome.io.rest.core.thing.ThingResource] - Received HTTP PUT request for update configuration at 'things/tankerkoenig:webservice:WebserviceName/config' for an unmanaged thing 'tankerkoenig:webservice:WebserviceName'.

Maybe the only problem is, that I can’t set the switch for “opening times” to get the “closed” state ignored…
How can I resolve the Problem with the unmanaged Thing?

Thank you in advance…

Regarding the station that us only reporting a price of zero instead of reporting closed.Yes that is one of those stations not sticking to the rules.
The error you are observing whin switching Opening Times I need to look into. However I have to postpone that until this weekend. I will report back!

@Ryan_Smith: to use proxy items is not a big deal. To set up the rules for the proxy items is also not a big Problem.
BUT:

  • your number of items increase to a much higher level as it have to
  • it is getting much more sophisticated to have a clear view to all items and their meaning
  • you need a rule for every proxy item
  • every time an update of the original item occurs you have to execute a rule

So if I can avoid the usage of proxy items I will do!

As I said: if my problem could be fixed with the “opening times” switch, everything is fine… (if I can solve the configuration error)

@Opus: Thank you for your effort…

Andreas

Regarding the number of rules I have to disagree. Use a trigger that fires on every change of each “direct” Item and you are set.

I did take a closer look on your logs. The “missbehaving” station is sending “wholeday=true”, that should say that the station is open all day. If it is closing and therefore reporting a price of zero there is nothing the binding could do! Not even the mode Opening Times (which I created just for stations that are closing) will help, since the station states it is open all day. Sorry for that.

What is the observed error? You posted an “Info,” report, if you are talking about that, it is no problem! The binding should work as expected.

I’m not sure what you are talking about by:

" I can’t set the switch for “opening times” to get the “closed” state ignored…"
The closed channel is totally separated from the mode OpeningTimes. The closed channel just gives the boolean info if the station is actually reporting to be open ( which your faulty station most probably does the whole day). The mode opening times uses the reported WholeDay info and if needed the reported times in order to save the times for later use. I don’t see why you would try to ignore anything here.
You might come up with the idea to automatically set the Open channel to false if the reported price is zero. Since I have had reports of stations that sell only a subset of the fuel-types and do report a zero price for the other types, I will not do a change in that direction.

Hello opus,

just to clarify: the station which reports “wholeday”:true is reporting the price over the night. As in the logs from 03:29:22 the update of the price is working for the station with state open and the other stations report “closed”. The item for the open station is updated to the transferred price and for the closed stations the item is updated to 0,00 EUR. @Dibbler42 told me that this behaviour is a feature and it works as designed.

As you told me I should use the mode “OpeningTimes” in the binding. If I set this option in PaperUI and save the settings, I get the message on the screen “Thing updated” followed by the message “Error 409: conflict”. The same time the said INFO for update a configuration for an unmanaged thing occured in the logs. And if I go back to edit the “Opening Times” again, the option is deactivated.

Maybe I should reinstall the binding to see if it is a configuration fault by myself.
I’m very sorry to waste your time. As said, I’m new to openHAB2 and it’s a little bit different from openHAB1…

Got it working. Last try before reinstallation was manual editing things file /etc/openhab2/things/tankerkoenig.things with "modeOpeningTime=true.

Now the items stays on the last price if the station is closed. Works as expected.

Don’t know why I couldn’t change the OpeningTime in PaperUI…

Thank you.

Thanks for that feedback.
If you are using this mode, remember that it does not know by itself if the actual day is a holiday! In case of a holiday during the week, on which the Sunday opening times should be used, the times for that weekday will be used. To overcome that you need to create an boolean item that is set to true if the actual day is a holiday and link this item to the holiday channel of the webservice as discredit in the documentation.

(Edit)
Did some thinking on why you couldn’t change this mode via PaperUI If you were using the things file from the start, that would explain it! PaperUI can not overrule this file!