GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - hanunes/ha-madeira-fuel-prices: Weekly maximum fuel prices in Madeira (JORAM) for Home Assistant

BranchesTags
Open more actions menu

Latest commit

 

History

4 Commits
4 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
blueprints/automation/hanunes
blueprints/automation/hanunes
 
 
custom_components/madeira_fuel_prices
custom_components/madeira_fuel_prices
 
 
docs
docs
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
hacs.json
hacs.json
 
 
pytest.ini
pytest.ini
 
 
requirements_test.txt
requirements_test.txt
 
 

Repository files navigation

ha-madeira-fuel-prices

A Home Assistant custom integration with the weekly maximum fuel prices in Madeira (Portugal), as published in JORAM, the official journal of the Autonomous Region of Madeira.

The Regional Government sets the maximum retail prices every week. The order is published in JORAM, usually on a Thursday or Friday, and applies from 0:00 on the following Monday. The journal offers no data feed for these prices, so the project behind https://madeirafuelprices.fyi/ reads each order once and publishes it as a small JSON file, which this integration fetches.

This is an unofficial project, not affiliated with the Regional Government. The journal is the authority; check it if a price matters.

Features

  • Sensors for the prices in force today: petrol 95, road diesel, and coloured (agricultural) diesel, in €/L.
  • Sensors for next week's prices, as soon as the order is published (unknown until then).
  • The date the current prices started and the date the next ones start.
  • Prices switch to the new order at 0:00 in Madeira on the day it starts, without waiting for the next fetch.
  • Each sensor carries the journal issue it came from (source, source_url) and the Portaria the order cites (portaria).
  • Two diagnostic sensors tell you whether the data can be trusted: when it last changed, and how many warnings came with it.
  • Known prices are kept across restarts and while the feed is unreachable.

Sensors

Entity Meaning
sensor.madeira_fuel_prices_petrol_95 Petrol 95, price in force
sensor.madeira_fuel_prices_diesel Road diesel, price in force
sensor.madeira_fuel_prices_coloured_diesel Coloured and marked diesel, price in force
sensor.madeira_fuel_prices_valid_from Date the prices in force started
sensor.madeira_fuel_prices_next_petrol_95 Petrol 95, next order
sensor.madeira_fuel_prices_next_diesel Road diesel, next order
sensor.madeira_fuel_prices_next_coloured_diesel Coloured and marked diesel, next order
sensor.madeira_fuel_prices_next_valid_from Date the next order starts
sensor.madeira_fuel_prices_data_updated When the published data last changed
sensor.madeira_fuel_prices_warnings Number of warnings that came with the data; the codes and messages attributes list them

In a normal week the data changes on Friday or Saturday and again on Monday. To be told when something is wrong, notify when data_updated is more than 8 days old or warnings is above 0. The warning codes are listed in docs/feed.md.

Installation

HACS (recommended)

  1. In Home Assistant, open HACS.
  2. Select the three-dot menu → Custom repositories.
  3. Add https://github.com/hanunes/ha-madeira-fuel-prices with category Integration.
  4. Install Madeira Fuel Prices.
  5. Restart Home Assistant.

Manual

  1. Copy the custom_components/madeira_fuel_prices folder into your Home Assistant config/custom_components directory.
  2. Restart Home Assistant.

Configuration

  1. Go to Settings → Devices & Services → Add Integration.
  2. Search for Madeira Fuel Prices and follow the prompts.

There is nothing to set. Only a single instance of the integration is supported.

Notifications (blueprint)

An optional automation blueprint sends a notification when next week's prices are published, with each price and its change against the prices in force:

New fuel prices
From Mon 19 Oct:
Petrol 95: 2.035 €/L (+3.2 c)
Diesel: 2.085 €/L (−0.6 c)

Import the blueprint

Or import it by hand: Settings → Automations & Scenes → Blueprints → Import Blueprint, with the URL https://github.com/hanunes/ha-madeira-fuel-prices/blob/main/blueprints/automation/hanunes/madeira_fuel_prices_notify.yaml. Then create an automation from it and choose:

  • Phones that get the message (Home Assistant Companion app), and optionally other actions (Telegram, a speaker, …), which can use the title and message variables.
  • Language: English or Português.
  • Fuels: petrol 95, diesel, coloured diesel.
  • What to notify: a new order is published (on by default; weeks with unchanged prices are skipped), the new prices take effect on Monday at 0:00 (off by default), a reminder to fill up before the change (off by default; you choose how many days before and at what time, e.g. Sunday at 18:00, and by default it is sent only when a selected price goes up), and a daily check for data problems (a warning from the feed, or no update for more than 8 days; on by default, at 09:00).

The entity fields are pre-filled with the integration's standard entity ids; change them only if you renamed the entities.

How it works

  • Once an hour the integration fetches one small file, https://madeirafuelprices.fyi/api/v1/prices.json, which holds the order in force and the next one. A job there reads JORAM once a day. The file's format is described in docs/feed.md.
  • The order in force is worked out from each order's start date and today's date in Madeira (Atlantic/Madeira), whatever Home Assistant's own time zone is.
  • The last valid copy of the file is kept. A fetch that fails, or an answer that is not valid, changes nothing.

Troubleshooting

  • Setup keeps retrying, "could not fetch the price feed": the feed did not answer and no prices are known yet. Setup tries again by itself.
  • Prices look out of date: check the data_updated and warnings sensors. If the data is more than 8 days old and there is no no_new_order warning, the job that reads JORAM has probably stopped; please open an issue.
  • For more detail, enable debug logging for custom_components.madeira_fuel_prices.

Development

pip install -r requirements_test.txt
pytest

The feed's format and the rules for reading it are in docs/feed.md.

License

MIT

About

Weekly maximum fuel prices in Madeira (JORAM) for Home Assistant

madeirafuelprices.fyi

Topics

fuel-priceshacshome-assistanthomeassistant-integrationmadeira

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.