sanderdw / Dutch-Gas-prices-API

To run your own Dutch Gas prices API
6 stars 6 forks source link

Improved OCR, more gas types support and api for finding gas stations #2

Open Skons opened 3 years ago

Skons commented 3 years ago

This PR adds the gas types euro98 and lpg to the gas_prices.py output. To accommodate this, a breaking change is created for the output. benzine_prijs and diesel_prijs no longer exists in the output. The assumption is that every gas station sells Diesel and Euro95, so they are both still to be expected to be present.

OCR is improved by converting the image to greyscale and by enlarging the image. This resulted in a better OCR result, especially for LPG. There is also a logo replacement (draw rectangle) to prevent tesseract to read text in a logo. The way the fuel types are "read" by the code is, what i think, also improved. I could not really figure out why Euro95 was explicitly defined in gas_prices.py, so i hope i provided a solution that fits that bill.

Last but not least gas_stations.py is added so you now can search for a gas station in the vicinity. For Home Assistant, a rest api would look like this. http://server:5035/api/v1/gas_stations/euro95?longitude={{ state_attr("zone.home", "longitude") }}&latitude={{ state_attr("zone.home", "latitude") }}

Please let me know what you think. If you think improvements are needed, i would happily add those.