# Home Assistant: track your favourite fuel stations

**Date:** 2024-09-20  
**Author:** Kees C. Bakker  
**Categories:** Automation  
**Original:** https://keestalkstech.com/home-assistant-track-your-favourite-fuel-stations/

![Home Assistant: track your favourite fuel stations](https://keestalkstech.com/wp-content/uploads/2024/09/maarten-van-den-heuvel-GauaGfBR6No-unsplash.jpg)

---

There is so much fun stuff you can do with Home Assistant. I like the fact that you can build a personal dashboard to monitor all sorts of things. So why not track fuel prices in your region? Yesterday I built this card to show the price of E10 at my favourite fuel stations:

![A screenshot of a Home Assistant card that shows a small list of gas stations and their prices for E10 fuel.](https://keestalkstech.com/wp-content/uploads/2024/09/image-2.png)
*A screenshot of a Home Assistant card that shows a small list of gas stations and their prices for E10 fuel.*

## The plan

So what do we need?

1. [ha-fuelprices](https://github.com/pantherale0/ha-fuelprices) - this will import the fuel prices. [These countries are supported](https://github.com/pantherale0/pyfuelprices?tab=readme-ov-file#datasources).
2. [Flex Table Card](https://github.com/custom-cards/flex-table-card) - this will show the table.
3. [Auto-entities](https://github.com/thomasloven/lovelace-auto-entities) - this will gather the "right" fuel stations.

After installing the integration and downloading the UI elements, we'll add a card to the dashboard.

## Installation

First, you'll need to add the [ha-fuelprices](https://github.com/pantherale0/ha-fuelprices) as a custom repository to HACS:

1. Click *HACS*
2. Top right hamburger menu > *Custom repositories*
3. *Repository*: https://github.com/pantherale0/ha-fuelprices
4. *Type*: Integration
5. Click the *Add* button

Next, you'll need to download the integration:

1. Click *HACS*
2. Search for *Fuel Prices*
3. Click right hamburger menu > *Download*
4. We're going to do the same for two UI elements we'll need. Search and download: *Flex Table* and *auto-entities*
5. You probably need to restart Home Assistant.

Now, you'll need to initialize the integration:

1. Click *Settings* in the right menu
2. Click *Devices & Services*
3. Click on the *Add Integration* button in the bottom left corner
4. Search for *Fuel Prices* and click the integration.
5. Complete the wizard.

I set the refresh time to 120 minutes instead of 1440 minutes (1 day). This will give more frequent updates.

## Building the fuel card

We're now ready to add the card to your dashboard. Click the bottom right *Add Card* button in your dashboard. Search for the card named *auto-entities*. Click on the button *Show Code Editor* and paste the following YML:

```yaml
type: custom:auto-entities
filter:
  include:
    - integration: fuel_prices
      attributes:
        postal_code: /^(8014[A-Z]{2}|8024AB|8024AA)$/
  exclude: []
sort:
  method: attribute
  attribute: E10
  reverse: false
  numeric: true
card:
  type: custom:flex-table-card
  columns:
    - data: E10
      name: Price
    - data: brand
      name: Name
    - data: address
      name: ''
```

Looks simple right? Observe the following:

- To show the "right" fuel stations, I use a regular expression that filters on postal codes. You might want to filter on different fields.
- I'm only interested in the price of E10, but you might be looking for B7, LPG, E5, or CNG.
- The address field does not have a heading to keep things clean.

And that's it! Enjoy.
