Skip to main content

Home Assistant Client library for Carbon Intensity API - Adds work by jfparis and alanmcgore to expose additional forecasts and percentage renewables

Project description

carbonintensityforked

Maintained

Simple Carbon Intensity UK API Library

The purpose of this library is to retrieve information from Carbon Intensity UK

The client connects asynchronously to the API, retrieving information about the current level of CO2 generating energy in the current period.

It uses aiohttp to communicate with the API asynchronously. This decision has been based mainly on the premise that the library will be used in the context of Home Assistant integration.

In addition it calculates when is the next 24 hours lowest level comparing values of the CO2 forecast levels.

This version also adds in a regional low carbon generation percentage, which is calculated as nuclear + wind + solar + biomass + hydro as well as the work by @jfparis to implement optimal windows/forecasts.

.2 Adds a regional fossil fuel generation percentage which calculates as gas + coal generation from the current window. .3 Adds oil and calls 48h service.

Example

Retrieve regional and national information based on postcode SW1 for the next 24 hours starting now:

   client = Client("SW1")
   response = await client.async_get_data()
   data = response["data"]

Note: Time in UTC

Data format

An example of the function output can be found below:

   {
       "data":
        {
              "current_period_from": "2020-05-20T10:00+00:00",
              "current_period_to": "2020-05-20T10:30+00:00",
              "current_period_forecast":300,
              "current_period_index": "high",
              "current_period_national_forecast":230,
              "current_period_national_index": "moderate",
              "current_low_carbon_percentage": 23,
              "current_fossil_fuel_percentage": 65,
              "lowest_period_from":"2020-05-21T14:00+00:00",
              "lowest_period_to":"2020-05-21T14:30+00:00",
              "lowest_period_forecast": 168,
              "lowest_period_index": "moderate",
              "optimal_window_from" : "2020-05-20T10:00+00:00",
              "optimal_window_to" : "2020-05-20T10:30+00:00",
              "optimal_window_forecast" : 121,
              "optimal_window_index" : "low",
              "optimal_window_48_from" : "2020-05-20T10:00+00:00",
              "optimal_window_48_to" : "2020-05-20T10:30+00:00",
              "optimal_window_48_forecast" : 130,
              "optimal_window_48_index" : "low",
              "unit": "gCO2/kWh",
              "forecast": [{"from":"2020-05-20T10:00+00:00","to": "2020-05-20T11:00+00:00", "intensity": 162, "index": 0, "optimal": False}],
              "postcode": "SW1"
        }
    }

Install carbonintensity

python3 -m pip install -U carbonintensity-forked

Licenses

This work is based on the following:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

carbonintensityforked-0.0.3.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

carbonintensityforked-0.0.3-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file carbonintensityforked-0.0.3.tar.gz.

File metadata

  • Download URL: carbonintensityforked-0.0.3.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for carbonintensityforked-0.0.3.tar.gz
Algorithm Hash digest
SHA256 60b7bf4e5c967ab6765aea69b32670a930560b691169c3b41cfda6f49f42627b
MD5 154f716d098d10861bb8e421c1a0ce29
BLAKE2b-256 945b269d69671d1c7a1679793b9ee8a003b5839234f405af2753af2a96829ba8

See more details on using hashes here.

File details

Details for the file carbonintensityforked-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for carbonintensityforked-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ca51f44914f5cd24fac604dc20c1699662173a45f81ea1485577244e5263d312
MD5 506cb58e7eb55480c3d32ed855fa244a
BLAKE2b-256 0d5b15dcd4e8a40a7913c3f30ed736c46fa1ea23e7e8e3e279f6f2bdf20dbe7c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page