Dutch Gas Priceses


A little while ago someone created a way of showing German gas priceses for their favorite gas station.
Sadly enough I don’t live in Germany but in the Netherlands and I would like to have a way for Home Assistant to show me where I can get the cheapest gas around my home.

This topic was discussed in another topic quite briefly and we mentioned starting a new topic for it so here we are. I will include the previous conversation about this topic below. Right now I am albe to monitor Shell gas stations but they are a little far away from me and quite expensive most of the time.

@Bob_NL & @metbril

1 Like

To reply to your latest post @metbril

The Direct Lease Tank Service indeed uses the images to show gas priceses sadly enough. Th thing that it does to is show pins on the map (coloured) based on how expensive the gas is there. I suppose that it has to get that data from somewhere. Maybe there is a way to show the one with the greenest pin in Home Assistant?

Just trying to think allong with this one.

It does also seem to sort the gas station on the right based on cheapest to most expensive one.

I don’t have any time to hack this, but the other day I used the Chrome developer tools to examine the loaded javascript. There is one that has ‘tankservice’ in the filename. That should point you in the right direction.

I did some testing and found this script working more or less.

import requests
from bs4 import BeautifulSoup

# url = "https://www.unitedconsumers.com/tanken/informatie/brandstof-prijzen/euro95"
url = "https://www.unitedconsumers.com/brandstofprijzen"

page = requests.get(url)

soup = BeautifulSoup(page.text, 'html.parser')

fuels_list = soup.find(class_='table')

fuels = fuels_list.find_all(class_='row table-row')

for fuel in fuels:
	fuel_name = fuel.find('a').contents[0].strip()
	fuel_price = fuel.find(class_='col-xs-4 col-sm-4 text-right').contents[0]
	print(fuel_name, fuel_price)

This could be implemented with the scrape sensor or with a custom component. The latter looks like fun to me, and I will give that a try.

Nice that you actually might have something working. Let me know if this works. Too bad it’s the “advies” prijs and not the current price at a gas station. They usually differ quite a lot.

I tried debugging the Android App yesterday (Direct Lease Tank Service) to figure out what API they call but could not figure it out yet. I’m a complete noob at this stuff. I will check the website in a bit. Since you mentioned the JAVA script that is called.

For future reference, from the other thread:

Original thread:

Scrape Shell Express

Get all stations from Directlease Tankservice


Station by image



United Consumers




1 Like

With some trial and error, I managed to retrieve the Euro 95 price with the scrape component:

      friendly_name: "Diesel"
      unit_of_measurement: "€/l"
      icon: mdi:gas-station
      friendly_name: "Euro 95"
      unit_of_measurement: "€/l"
      icon: mdi:gas-station
      friendly_name: "LPG"
      unit_of_measurement: "€/l"
      icon: mdi:gas-station

  - platform: scrape
    name: Euro95
    resource: "https://www.unitedconsumers.com/brandstofprijzen"
    select: ".table div:nth-of-type(8)"
    value_template: "{{ value.split(' ')[1].replace(',', '.') | float }}"
    scan_interval: 3600 # be nice; once per hour only

  - platform: scrape
    name: Diesel
    resource: "https://www.unitedconsumers.com/brandstofprijzen"
    select: ".table div:nth-of-type(14)"
    value_template: "{{ value.split(' ')[1].replace(',', '.') | float }}"
    scan_interval: 3600 # be nice; once per hour only

  - platform: scrape
    name: LPG
    resource: "https://www.unitedconsumers.com/brandstofprijzen"
    select: ".table div:nth-of-type(20)"
    value_template: "{{ value.split(' ')[1].replace(',', '.') | float }}"
    scan_interval: 3600 # be nice; once per hour only

That was fun, and useful.

Update: while I’m still at it, I added the diesel and LPG.



1 Like

@Bob_NL This is fun… I managed to scrape the Euro 95 price of one of the cheapest gas stations near my home (and perhaps near you). It’s from TINQ.

      friendly_name: "Euro 95 (Bermweg)"
      unit_of_measurement: "€/l"
      icon: mdi:gas-station

  - platform: scrape
    name: Euro95 Bermweg
    resource: "http://www.tinq.nl/tankstation?id=251"
    select: "#station-prijzen tr:nth-of-type(3) td:nth-of-type(2)"
    value_template: "{{ value.split('\xa0')[1].replace(' ','').replace(',', '.') | float }}"
    scan_interval: 3600 # be nice; once per hour only
1 Like

@Bob_NL Your scrape sensor can be improved by making an actual value of it:

value_template: '{{ value.split(" ")[0] }}'

should be replaced with

value_template: '{{ value.split(" ")[0].replace(",", ".") | float }}'

This is awesome man!
Combined it into a nice card for my Home Dashboard. Tinq is usually the cheapest near me aswell. Have to add a few more.

Thanks for the great developing :smiley:

I have Lukoil scraped, too. Look at my repo in the ‘fuel’


@metbril Thnx for sharing you’re setup!

For people who want to add pricing from Tango I’ve added the needed select value for it.

  • platform: scrape
    name: Euro95 tango
    resource: “https://www.tango.nl/stations/XXX#you’re desired location
    select: “#euro95 .pump_price span.price”
    scan_interval: 3600 # be nice; once per hour only
1 Like

Has anyone found a site with Avia prices?

The regular pages don’t show any:


Wow, what a coincidence. That is like a 5 minute drive from my home indeed. Small world!

I can’t get it to work (with or without the value_template).

  - platform: scrape
    resource: "https://www.tango.nl/stations/tango-nieuwerkerk-ad-ijssel"
    select: “#euro95 .pump_price span.price”
#    value_template: "{{ value.split(' ')[0].replace(',', '.') | float }}"
    scan_interval: 3600 # be nice; once per hour only 
2018-07-15 20:49:26 ERROR (MainThread) [homeassistant.components.sensor] scrape: Error on device update!
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 319, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/scrape.py", line 120, in update
    value = raw_data.select(self._select)[0].text
IndexError: list index out of range

Same with me. I did not have the tome to look into this, but the error was the same.

@Joey_Germeraad @metbril
My knowledge is too limited to decipher this unfortunately, but I see the following lines in the source:
Does it work without the “#euro95” or with “pricing open” perhaps? At the moment I’m unable to test this myself.


I’ll check you’re specific tango station tonight. It’s strange that the exact same setup with a different station is giving you errors. You mentioned it allready, but just checking, are you using the value_ template? In my setup the Tango.nl scraper would only work without the Value_template.

The main reason for adding the #euro95 is because the classes open and pricing are to generic, there are more divs on the page that have these classes which will result in Errors.

I tried both with and without the value_template.