Python bindings for the Elvia API
Project description
Unofficial API bindings for Elvia's consumer facing APIs
With the Elvia API you can access information about your own power consumption and get the current grid tariffes in Elvia's power grid.
Installation
Install from pip by using:
pip install --upgrade elvia
Requirements
- Python 3.6+
Getting access tokens
Elvia's APIs are available for consumers using Elvia for their grid fees (nettleie).
The MeterValue and GridTariff APIs uses different authentication methods, and different tokens.
Meter Value API
Get token using this guide: https://www.elvia.no/smart-forbruk/alt-om-din-strommaler/slik-gjor-du-det-aktivering-og-bruk-av-elvias-metervalueapi/
Grid Tariff API
Get token by logging into https://elvia.portal.azure-api.net/signin and subscribe to the GridTariffAPI
Using the API
from elvia import Elvia
import json
import asyncio
import os
# token from elvia.no/minside
meter_value_token = os.environ.get("ELVIA_METER_VALUE_TOKEN")
# token from https://elvia.portal.azure-api.net/signin
grid_tariff_token = os.environ.get("ELVIA_GRID_TARIFF_TOKEN")
# the metering point id of your home
metering_point_id = os.environ.get("ELVIA_METERING_POINT_ID")
elvia = Elvia(meter_value_token = meter_value_token)
async def get_meter_values():
meter_value_client = elvia.meter_value()
meter_values = await meter_value_client.get_meter_values(
start_time = "2021-12-08T01:00:00",
end_time = "2021-12-08T02:00:00",
metering_point_ids = [metering_point_id],
include_production = True
)
print(json.dumps(meter_values))
asyncio.run(get_meter_values())
# And use it to get grid tariffs
elvia = Elvia(grid_tariff_token = grid_tariff_token)
async def get_grid_tariffs():
grid_tariff_client = elvia.grid_tariff()
grid_tariffs = await grid_tariff_client.grid_tariffs_for_metering_points(
range = "today",
metering_point_ids = [metering_point_id]
)
print(json.dumps(grid_tariffs))
asyncio.run(get_grid_tariffs())
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
File details
Details for the file elvia-0.1.0.tar.gz
.
File metadata
- Download URL: elvia-0.1.0.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd4362cf85d78a068783b55abcdd90fe83f83fbf99ce8ed26ee33a3a065c7b0b |
|
MD5 | f5dc8f26fb6b7d271e6ad3468435341c |
|
BLAKE2b-256 | d2d0f0081cdabb8ddd80c66437545e0a7aa0f8ac547f363d38645a3e838415f4 |