Skip to content
A script to scrape fuel prices from the portuguese fuel and fossil authority and publish them in your Home-assistant (Some assembly required)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
fuel.info.sh

README.md

Home-assistant-fuel-scrapper

Fuel prices scraper for Home-assistant

This utility gets the results of a search in a website so you can scrappe the values and add them to your Home-assistant as sensors.

The values are scrapped from the portuguese national energy authority,which only has values for fuel shops in Portugal.

After scrapping the values, it writes them directly to your Home-assistant through it's API. This means that you don't need to enter anything in your configuration.yaml.

This script should be runned from a server on a dailly bases. Find out how to add it to a scheduller like crontab.


HOW-TO

First of all, you need to find out the identifier for the fuel shop you want to control

  1. Open Firefox or Chrome developer tools (Usually pressing F12 key).
  2. Select the network tab from the development tools so you can see the requests.
  3. Go to http://www.precoscombustiveis.dgeg.pt/
  4. Find the fuel shop you want info from.
  5. Click on the shop so you can see the info
  6. In the developer tools, on the network tab, select only the XHR traffic.
  7. Click on the POST to the infoPostoCB.aspx
  8. On the details for the request, read the parameters sent (Params).
  9. Take note of the value for nppostocombustivel.

Now, lets configure the bellow variables for your Home-assistant and fuel shop:

Home-assistant

PROTOCOL="http" <-- Enter either "http" or "https", depending where your Home-sistant is listening

HOST_IP_OR_NAME="localhost" <-- Usually "localhost" is fine. If you are running is script from another computer other than the one running Home-assistant, enter ther a named address like "myserver.myhouse" or an internet protocol number (IP) like "192.168.1.20"

PORT_NUMBER="8123" <-- This is the port number your Home-assistant is listening.

HAPASSOWRD="SomePassword" <-- You shouldnt leave you Home-assistant running thout a password. Enter yours here. Its the same password you entered for i_password: at configuration.yaml

Shoe Fuel shop friendly names in Home-assistnat

SHOWFUELSHOPLOCATION="nppostocombustivel nppostocombustivel nppostocombustivel" <-- In the first step you got this from the nppostocombustivel value. Enter each nppostocombustivel separated by a space.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.