Fuel/Gas Prices integration

Hi all,

I’ve built an integration to pull gas (fuel) prices from multiple datasources, with support for a number of worldwide data providers.

Some of these sources are official, however the majority are reverse engineered mobile apps. Currently this integration supports:

  • Australia: Fuel Watch, FuelSnoop, PetrolSpy
  • Austria: Spritpreisrechner
  • Belgium: DirectLease
  • Brazil: GasPass (proxied)
  • Canada: GasBuddy
  • Germany: TankerKoenig
  • Netherlands: DirectLease
  • UK: Apple Green Stores, Ascona, Asda, BP, Esso, Jet, Morrisons, Moto, Motor Fuel Group, Rontec, Sainsbury’s, SGN, Shell, Tesco, Karen Retail
  • New Zealand: PetrolSpy
  • Romania: Peco-Online
  • Switzerland: Comparis
  • USA: GasBuddy

Your home area is registered automatically during integration setup with a default radius of 5 miles, alongside this, the integration should be able to detect the correct data sources / configuration for your configured areas so no need to configure these manually. The option is still there however if you want to restrict where the integration looks for data.

If you have any more data providers or suggestions for sources, I welcome those requests :slight_smile:

Screenshots:


image
image


image


13 Likes

looks nice!!! hope Netherlands will follow :slight_smile:

Would be great to load in that sources for other countries, but need to find reliable feeds first.

It seems the UK is now part of the minority when it comes to publishing fuel prices.

Well done! Not quite working, though.

I’m getting fuel prices as attributes of the fuel station device tracker, but in Developer Tools I don’t get the service in your image. Only two:

  • Fuel prices: find_fuels
  • Fuel prices: find_fuel_station

In the Developer Tools service pages I can’t see a way to enter the location. It’s shown correctly on the map, but I get the error “please enter a valid value for location”.

Also, in the instructions on your GitHub page you say

  1. In the HA UI go to “Configuration” → “Integrations” click “+” and search for “Integration blueprint”

That should be ‘search for “Fuel Prices”’.

There is an add-on for dutch prices. But this works on mqtt base. Would be nice to have this mqtt away and directly integrated in HA.

The add-on I now use:

He using this API:

This is the GitHub page. Maybe you can do something with the information?

1 Like

This could be a translation problem more than anything, what language is your HA instance set to?

The two services you have listed are correct, “find_fuels” relates to the first service, “find_fuel_station” relates to the second service. I haven’t added the documentation though yet on how to use those so that’s on me.

Also, I did release another update to fix sort some translation issues out so try updating if you aren’t on the latest already.

also updated the readme too, thanks :slight_smile:

English! I must play some more.

This looks great, I’ve got it installed and am seeing the device_tracker entities for the stations with their prices but both of the services return empty lists if I try and run them through the developer tools.

I am pretty new to HA though so could well just have/am doing something wrong.

I found you might have to move the center point on the map slightly. There seems to be a “bug” in the frontend (or somewhere within home assistant) where it doesn’t send coordinates if you have only adjusted the radius or left it at its default.

Yep, that gets the list populated, easy work around, thank you!

1 Like

Hi,

Many thanks for the integration. Very useful!
As mentioned I have to drag the center point on the service call but apart from that it’s working well.
I’m still learning HA so wondering how best to display the prices in some table / grid form on a card. Any ideas appreciated.
Thanks. Great work.

Good thought, you might be able to use this as a starting point and the entity attributes can be used to retrieve the price.

Future plan might introduce a toggle setting between sensors and the device tracker platform but not too sure yet.

Thanks for the tip. I had the auto-entities integration installed but not put to much use.
So a little progress. Probably not the best method but at least its a start.

My local fuel station list was only 9 stations. I manually created an Area and assigned these entities to an area called ‘Fuel’.

On my dashboard I now can see the list of stations on a card.
It shows the name of the station and postcode.
I am now uncertain how to dig deeper and show the attributes of the station as well?

Code is:

type: custom:auto-entities
card:
  type: entities
  state_color: false
  show_header_toggle: true
filter:
  include:
    - area: Fuel
  exclude: []
sort:
  method: none
  numeric: false
show_empty: true

I will keep tinkering…

EDIT I now see I have not used the flex table card so will need to try this combination

1 Like

Not perfect, but I’ve just quickly put this together:

type: custom:auto-entities
filter:
  include:
    - integration: fuel_prices
  exclude: []
sort:
  method: attribute
  attribute: B7
  reverse: false
card:
  type: custom:flex-table-card
  columns:
    - data: friendly_name
      name: Name
    - data: E5
      name: Petrol Premium
    - data: E10
      name: Petrol
    - data: B7
      name: Diesel

Brilliant!

It might not be perfect but its almost perfect for me. Looks like some of my local stations don’t do Petrol Premium so they are showing as undefinedundefinedundefined in the colum but apart from that maybe a bit wider colums and its a cool integration to have an instant view of the local prices. Also a bit of an eye opener (as I knew) to the difference in price between a couple of miles.
Thanks again

1 Like

Same with me, I’ve removed the petrol premium column for myself as we only have 1 petrol car which doesn’t get that treatment anyway.

Did a search for all fuel stations in a 25 mile radius of myself and realised how expensive the fuels were in my local town which is equivalent of motorway prices.

Taken a look at this, parsed out a list of fuel stations from their API, some dodgy data in there (missing names and brands etc), however it does work, there is a performance penalty with pulling all the fuel price data (as I need to OCR it) so it will do that on demand if it hasn’t been collected yet, and will also update in the background after it’s been collected (set to once per day so it doesn’t bring Home Assistant to its knees).

Need to do some further testing in home assistant to see how well this will integrate, but things are looking promising :slight_smile:

2 Likes

Sometimes it’s easy to miss the obvious :slight_smile: I should of thought of that as I cannot remember the last time I used any premium fuel. Also removed the column and that’s cleaned things up nicely. Card looks fine now. Added to a dashboard, very useful.

I’ve noticed that some of the local stations are not detected. The main one’s I use are however.

Thanks.

It uses the feeds published at the link below, and I have myself noticed some missing retailers, my local mace garage for example is “Esso” fuel and branding but not actually operated by Esso so this doesn’t show up.

Promising news on the Netherlands / Belgium front. I’ve identified the endpoints that return the station data in JSON (rather than an image) by proxying the requests the mobile app makes. Need to figure out how to generate the checksum that is sent, but looking through the code for the mobile app, it appears to just be a SHA1 hash based on current date and time, random GUID and the file part of the URL. Example response below:

{
	"date": [
		2023,
		12,
		24
	],
	"id": 4747,
	"lat": 51.97354,
	"lng": 5.66068,
	"brand": "Total",
	"name": "Express",
	"city": "Wageningen",
	"country": "NL",
	"address": "v Uvenweg 119",
	"postalCode": "6708AE",
	"phoneNr": "0344614734",
	"services": [
		"unmanned",
		"gas247",
		"carwash"
	],
	"openingTimes": [
		{
			"types": [
				"fuel"
			],
			"mon": [
				0,
				2400
			],
			"tue": [
				0,
				2400
			],
			"wed": [
				0,
				2400
			],
			"thu": [
				0,
				2400
			],
			"fri": [
				0,
				2400
			],
			"sat": [
				0,
				2400
			],
			"sun": [
				0,
				2400
			]
		}
	],
	"fuels": [
		{
			"key": "e10",
			"name": "Euro 95 (E10)",
			"price": 1859,
			"nextPrice": 1919
		},
		{
			"key": "diesel",
			"name": "Diesel (B7)",
			"price": 1669,
			"nextPrice": 1749
		},
		{
			"key": "euro98",
			"name": "Euro 98 (E5)",
			"price": 2179
		},
		{
			"key": "diesel_special",
			"name": "Premium Diesel (B7)",
			"price": 1899
		}
	]
}
1 Like