Fuel/Gas Prices integration

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.

Great thank you. Just so I’m understanding this correctly, if I’ve set up the fuel stations I’m interested by defining the areas, then the fuel prices for those should update just by calling the find fuel service? Nothing else is needed to get them to update?

Yes, for the UK all fuel stations will update daily in the background.

In other countries there is a lot more logic added to update stations due to differences in how the APIs work. But generally those should also update roughly daily.

1 Like

For device tracker, only the name or the state can be shown on a Map card.
Do you know how to display only an attribute value (for example, E10 value) on a Map card?