Skip to main content

Home Assistant Client library for Carbon Intensity API

Project description

carbonintensity

Maintained BuyMeCoffee

Simple Carbon Intensity UK API Library

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

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

It uses aiohttp to communicate with the API asynchrnously. 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.

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",
              "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",
              "postcode": "SW1"
        }
    }

Install carbonintensity

python3 -m pip install -U carbonintensity

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

carbonintensity-0.3.0.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distributions

carbonintensity-0.3.0-py3.9.egg (5.3 kB view hashes)

Uploaded Source

carbonintensity-0.3.0-py3-none-any.whl (4.4 kB view hashes)

Uploaded Python 3

Supported by

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