Giter VIP home page Giter VIP logo

eon-api's Introduction


Version Version
E.ON Myline API wrapper

Features

  • Read messages
  • Get invoices
  • Download invoices

Install

$ pip3 install git+https://github.com/vrachieru/eon-api.git

or

$ git clone https://github.com/vrachieru/eon-api.git
$ pip3 install ./eon-api

Usage

Reading messages

from eon import EON

eon = EON('username', 'password')

message_page = eon.get_inbox()

print ('Page size: %s' % message_page.page_size)
print ('Start index: %s' % message_page.start_index)

print ('Total messages: %s' % message_page.total_count)
print ('Unread messages: %s' % message_page.unread_count)

is_unread = lambda message: not message.read
unread_messages = filter(is_unread, message_page.messages)

for message in unread_messages:
    message = eon.get_message(message.id)
    print('Id: %s' % message.id)
    print('Subject: %s' % message.subject)
    print('Date: %s' % message.date)
    print('Body: %s' % message.body)
$ python3 messages.py

Page size: 1
Start index: 0

Total messages: 128
Unread messages: 1

Id: 000000000
Subject: Bun venit!
Date: 2018-11-13 15:06:15
Body: 'Stimate client,\nBine ai venit pe portalul E.ON Myline!\nLinia ta direct\xc4\x83 cu noi \xc3\xae\xc5\xa3i ofer\xc4\x83:\nVizualizare \xc5\x9fi desc\xc4\x83rcare a facturii \xc3\xaen format electronic (prin activarea serviciului de factur\xc4\x83 electronic\xc4\x83)Notificare pe e-mail la emiterea facturii electronicePlata facturilor E.ON cu cardul pe platforma E.ON Myline f\xc4\x83r\xc4\x83 niciun comisionTrimiterea indexului contorului de gaze naturale \xc5\x9fi energie electric\xc4\x83 (dac\xc4\x83 a\xc5\xa3i optat pentru autocitirea contorului)Informa\xc5\xa3ii cu privire la verificarea periodic\xc4\x83 \xc5\x9fi revizia tehnic\xc4\x83 a instala\xc5\xa3iei tale de gaze naturaleGestionarea programului/conven\xc5\xa3iei de consumAbonarea la newsletter\xc3\x8entre\xc5\xa3inerea \xc5\x9fi actualizarea datelor tale de autentificarePosibilitatea modific\xc4\x83rii datelor de coresponden\xc5\xa3\xc4\x83\n\nPo\xc5\xa3i consulta ghidul utilizatorului E.ON Myline aici.\nEchipa E.ON Myline'

...

Reading invoices

from eon import EON

eon = EON('username', 'password')

invoice_page = eon.get_invoices('000000000000') # account_contract (you can find this in account settings via app; different for gas and electricity)

print('Total invoices: {}\n'.format(invoice_page.total_count))

print('Account balance: {}'.format(invoice_page.account_balance))
print('Unpaid value: {}\n'.format(invoice_page.unpaid_value))

for invoice in invoice_page.invoices:
    print('Number: {}'.format(invoice.number))
    print('Fiscal number: {}'.format(invoice.fiscal_number))
    print('Emission date: {}'.format(invoice.emission_date))
    print('Expiry date: {}'.format(invoice.expiry_date))
    print('Type: {}'.format(invoice.type.name))
    print('Value: {}'.format(invoice.value))
    print('Balance: {}'.format(invoice.balance))
    print('Payment status: {}'.format(invoice.payment_status.name))
    print('Bar code: {}'.format(invoice.bar_code))
    print('Electronic: {}'.format(invoice.electronic))

    for meter_detail in eon.get_invoice_meter_details(invoice.number):
        print('Consumption: {} m3 ({} KWH)'.format(meter_detail.consumption_cubic_meters, meter_detail.consumption_kwh))
        print('Old index: {}'.format(meter_detail.old_index))
        print('New index: {}'.format(meter_detail.new_index))
        print('Period: {} - {}'.format(meter_detail.period[0], meter_detail.period[1]))
$ python read_invoices.py
Total invoices: 18

Account balance: 203.99
Unpaid value: 203.99

Number: 000000000000
Fiscal number: 0000000000000000
Emission date: 2018-11-15 00:00:00
Expiry date: 2018-12-17 00:00:00
Type: CONSUMPTION
Value: 203.99
Balance: 203.99
Payment status: UNPAID
Barcode: 000000000000000000000000000000000000000
Electronic: False
Consumption: 113 m3 (1209.326 KWH)
Old index: 2595
New index: 2708
Period: 2018-10-03 00:00:00 - 2018-11-05 00:00:00

...

Downloading invoices

from eon import EON

eon = EON('username', 'password')

invoice_page = eon.get_invoices('000000000000') # account_contract (you can find this in account settings via app; different for gas and electricity)

download_path = '/home/user/documents/invoices/eon'

for invoice in invoice_page.invoices:
    print ('Downloading invoice #{}'.format(invoice.number))
    eon.download_invoice(invoice.number, download_path) # NOTE: This only works if you have electronic invoice activated.

License

MIT

eon-api's People

Contributors

vrachieru avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

cnecrea

eon-api's Issues

Official documentation

Is there an official documentation for the Eon API? I couldn't find anything online.
Thanks!

php

ceva in pentru php ai lucrat?

KeyError: 'xauth'

Hello.

Thanks for the great work on this project.
I've been trying to get this to work for myself but after configuring everything, when i try any of the possible actions i get the following error:

(eon-api) root@homeassistant:~/eon-api# python3 read_invoices.py
Traceback (most recent call last):
File "/root/eon-api/read_invoices.py", line 3, in
eon = EON('MY_EMAIL', 'MY_PASSWORD')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/eon-api/lib/python3.11/site-packages/eon/client.py", line 24, in init
self._token = self.login(username, password)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/eon-api/lib/python3.11/site-packages/eon/client.py", line 43, in login
return response.headers['XAuth']
~~~~~~~~~~~~~~~~^^^^^^^^^
File "/root/eon-api/lib/python3.11/site-packages/requests/structures.py", line 52, in getitem
return self._store[key.lower()][1]
~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'xauth'

Is there something that i am doing wrong or is this no longer working due to some changes made by e.on?

Thanks!

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.