Fuel/Gas Prices integration

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

You speak agragafabra to me now hahaha. I wish I can code that way… Happy to see progess

Had to completely rewrite most of the underlying module to account for different data sources that don’t return everything in one go, but I’ve just released the first beta that includes support for; DirectLease (both Belgium and Netherlands), GasBuddy (USA), TankerKoenig (Germany), FuelWatch (West Australia).

Any issues please report :slight_smile:

2 Likes

Hi, thanks for your efforts. Keen to track the progress of this integration.

I installed the new version and can see the data from the developers / services method.
The full list populates of the local stations.
One issue however is the table I added to my dashboard that you shared below does not show any data.
Thanks!

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

Please ignore. Not sure what I did wrong but now works. Thank you.

No problem, note for anyone else, that card is only tested with UK data, changing the columns to fuel types available in your area should provide the same result.

Whoop whoop. Later this day I’ll install your tool and will come back with results for Netherlands!!!

Everything done. But when I try to add a integration it stay on this screen:

## Error

Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble

Unstable. After HA restart it configuration screen stay there forever.

Thanks for reporting, not sure whats happened here, just released a newer version, can you try that please? https://github.com/pantherale0/ha-fuelprices/releases/tag/2024.1.0b2

EDIT: Actually seems to be some dependency problems that have been reported a few times on the forum (search numpy)

With this beta I only get this line even with debug on:

2024-01-05 14:37:42.838 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading flow for integration fuel_prices: No module named 'sklearn'

The integration show me this:

## Error

Config flow could not be loaded: {"message":"Invalid handler specified"}

Yeah, thats what I expect now.

Seems like I’m not the only one who has hit this problem with one of the dependencies :confused:

https://community.home-assistant.io/t/how-to-use-scikit-learn-with-a-custom-intigration/

Apologies for this, re-download 2024.1.0b0 from hacs (or manually install again).

I’ve reluctantly restarted the betas for this release and removed the performance optimizations as I can’t get around the dependency problems.

That being said, if you define an area with a large radius, it will probably take some time to load fully.

Removed the fder. Add location to HACS as custom link. Add latest beta and now I can do the setup!!

I was needed to convert miles to km. (we use km here) haha

It’s fast to see 18 device_trackers added to the integration.

I’m on a Dell 3050 mini pc

Maybe a idea to create a option to calculate the 5 lowest gas stations within the given radius? The device_trackers names are always:

device_trackers.lowest_gas_1
device_trackers.lowest_gas_2
device_trackers.lowest_gas_3
device_trackers.lowest_gas_4
device_trackers.lowest_gas_5

And the content of them change because nit always the same station is the lowest.

I’m using this to want add them in a map. So we see where in the area the lowest price will be.

P.s. //keep up the good.work. I wish I can write code like this… But started learning python haha

Sorry!!

Modify information. Gives errors.
I can’t add a second service for.different location.
Maybe this is a expected behavior because of the code.

I will change log to debug later the day and play around to collect logs.

Yes, you can’t change the options yet as I’ve not completed the OptionsFlow for it.

1 Like

This is awesome, thank you for creating this!
I’m working on an automation using this that updates the fuel prices and sends me and my wife a notification every morning with the top 3 fuel stations by lowest petrol price. I was trying to include a “Last Updated” datetime but it doesn’t look like the Last Updated Time of the device tracker entity gets updated when the fuel prices are updated. Is it possible to add an updated time attribute to the entites at all or am I looking in the wrong place?

1 Like

The last updated attribute is a recent addition to the underlying library. I’ve noticed the same thing too so will take a look and see if it’s home assistant causing a fuss or just a attribute not fully implemented in the lib yet.