Gas price via Tankerkönig (Germany)

I’ve created a lovelace card for the component.

I think with the card and the component it is a low easier to configure it.

Thanks for the card.
Unfortunately the € sign is not displayed correctly.
image
Any idea what is causing the issue?

It would furthermore be great if you could add following feature:
Open sensor info dialog on clicking on the price

I was able to fix this by changing line 77 to:

value="${state.state} €"

1 Like

Is there a way to keep the prices shown, when a gas station is closed? Because it will show ‘unknown’ when the station is closed.

@napsio

They have changed the directory structure of custom components beginning with HA 0.88.

See blog post: https://developers.home-assistant.io/blog/2019/02/19/the-great-migration.html

Tankerkönig is still working but needs to be modified to work with the new structure in newer HA versions.

I have tried a modification to the new needs but it is not working as expected.

Could you please help and have a look at the issue?

ImportError: No module named 'custom_components.tankerkoenig.sensor'; 'custom_components.tankerkoenig' is not a package
2019-03-23 20:29:46 WARNING (MainThread) [homeassistant.loader] Integrations need to be in their own folder. Change sensor/tankerkoenig.py to tankerkoenig/sensor.py. This will stop working soon.
2019-03-23 20:29:46 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.tankerkoenig.binary_sensor. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/loader.py", line 166, in _load_file
    module = importlib.import_module(path)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked

ImportError: No module named 'custom_components.tankerkoenig.binary_sensor'; 'custom_components.tankerkoenig' is not a package
2019-03-23 20:29:46 WARNING (MainThread) [homeassistant.loader] Integrations need to be in their own folder. Change binary_sensor/tankerkoenig.py to tankerkoenig/binary_sensor.py. This will stop working soon.
2019-03-23 20:29:46 ERROR (MainThread) [homeassistant.loader] Error loading custom_components.tankerkoenig.sensor. Make sure all dependencies are installed
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/loader.py", line 166, in _load_file
    module = importlib.import_module(path)
  File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked 

Thank you.

Update: Solved! Sorry, did not know that there was released an update for this issue.
Updated the component to 0.2.0 and now it is working as expected.

How have you done with French price ?

Thanks

Is this component still maintained? I am seeing an errror since a longer time due to the fact that HA is restructering the custom components, but on Github the last change is 4 month ago. This is the error:

Wed Jun 26 2019 21:44:52 GMT+0200 (Mitteleuropäische Sommerzeit)
Unable to find services.yaml for the tankerkoenig integration

Hi,

I’ve a script that download a zip file on the government webpage. It’s cron at 8 AM each morning.

#!/bin/bash
cd /home/homeassistant/
sudo rm PrixCarburants_instantane.xml
sudo rm instantane*
sudo wget https://donnees.roulez-eco.fr/opendata/instantane  
sudo mv instantane instantane.zip
sudo unzip instantane.zip

I’ve some other script for each gaz station (named here gazole.sh) I need to get the value :

#!/bin/bash
cd ~
xmllint --xpath '//pdv[@id="xxxxxxxxxxxx"]//prix[@nom="Gazole"]/@valeur' /home/homeassistant/PrixCarburants_instantane.xml | awk -F= '{ print $2 }' | sed s/\"//g

xxxxxxxx should be the id of the gaz station you need it the file and in HA a sensor like :

sensor : 
- platform: command_line
  name: "gazole intermarche"
  command: "/bin/bash /home/homeassistant/.homeassistant/gazole.sh"
  unit_of_measurement: "€"

It’s very dirty but it does the job very well. (but it does not work if you use docker I think)

For your information, I have create a custom_component for the French gas station : GitHub - ldb2000/carburant-sensors: Carburant price for home assistant France

Nice but it will download many times the same file in a day. This one is only update once a day…

I know that it is not perfect. I just would like to share if someone need it.