Coder Social home page Coder Social logo

elvia-python's Introduction

Unofficial API bindings for Elvia's consumer facing APIs

Build Status

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())

elvia-python's People

Contributors

andersem avatar sverresto avatar

Watchers

 avatar  avatar

Forkers

sverresto

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.