Skip to content

Rene-Sackers/VattenfallDynamicPriceApi

Repository files navigation

Vattenfall dynamic price scraper & API

THIS PROJECT IS NOT CREATED, AFFILITED, ENDORSED OR SPONSORED BY VATTENFALL

Seeing as of the time of writing, there is no official API to get hourly prices from Vattenfall, I have made this application to scrape them off of the following page: https://www.vattenfall.nl/klantenservice/alles-over-je-dynamische-contract/

Endpoints

URL Description
/v1/data Provides parsed data from Vattenfall
/v1/evcc Provides data compatible with EVCC
/v1/now/electricity Provides the current price for electricity
/v1/now/gas Provides the current price for gas

Environment variables

You should not have to configure these, but they're available just in case.

Var Default Description
ASPNETCORE_URLS http://+:8080 What ip/port the web app should bind to
VFAPI_UseKnownValues false If the live page ever changes, causing part of the scraping to fail, setting this to true causes the app to use VFAPI_KnownApiBaseUrl and VFAPI_KnownApiKey. These will need to be manually endered as well. If set to false, it will figure it all out automatically.
VFAPI_ScrapePageUrl The page to try and get the API base URL and key from
VFAPI_KnownApiBaseUrl The base URL of the API endpoint
VFAPI_KnownApiKey The API key
VFAPI_RefreshIntervalSeconds 3600 The time between API data refreshes

Docker compose

name: vattenfalldynamicpriceapi
services:
  vattenfalldynamicpriceapi:
    container_name: vattenfalldynamicpriceapi
    image: ghcr.io/rene-sackers/vattenfall-dynamic-price-api:latest
    environment:
      - TZ=Europe/Amsterdam
    ports:
      - 8080:8080

Example EVCC tariffs config

currency: EUR

grid:
  type: custom
  forecast:
    source: http
    uri: https://example.com/v1/evcc

Example Home Assistant sensor

# configuration.yaml

sensor:
  - platform: rest
    name: "Vattenfall Current Electricity Price"
    resource: https://example.com/v1/now/electricity
    unit_of_measurement: "€/kWh"
    device_class: monetary
    state_class: measurement
    icon: mdi:currency-eur
    scan_interval: 300

  - platform: rest
    name: "Vattenfall Current Gas Price"
    resource: https://example.com/v1/now/gas
    unit_of_measurement: "€/m³"
    device_class: monetary
    state_class: measurement
    icon: mdi:currency-eur
    scan_interval: 300

About

**NOT OFFICIAL** scraper to get hourly prices from the Vattenfall website

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors