Skip to main content

Asyncio library for SVK Mimer

Project description

aiosvkmimer

Asyncio library for SVK Mimer https://mimer.svk.se/

UNDER DEVELOPMENT!!!

Example

#!/usr/bin/env python3
import asyncio
import logging
import pprint

from aiosvkmimer.client import Mimer
from prettytable import PrettyTable

# settings
AVAILABLE_KW = 8
LOGGING_LEVEL = logging.INFO
PERIOD_FROM = '2023-09-01'
PERIOD_TO = '2023-09-01'

# configure logging
logging.basicConfig(
    format='%(asctime)s.%(msecs)03d %(levelname)s %(module)s - %(funcName)s: %(message)s',
    datefmt='%Y-%m-%d %H:%M:%S',
    level=LOGGING_LEVEL
)

def nice_price_output(prices, prices_sum, description):
    table = PrettyTable()
    table.field_names = ['Date', f'{description} Price (SEK)']
    table.align = 'l'
    table.padding_width = 2
    for date, price in prices.items():
        table.add_row([date, price])
    table.add_row(['Total', prices_sum])
    print(table)

async def main():
    mimer = Mimer(
        kw_available=AVAILABLE_KW
    )
    await mimer.fetch(
        period_from=PERIOD_FROM,
        period_to=PERIOD_TO
    )

    prices_fcr_n = mimer.get_fcr_n_prices()
    prices_fcr_d_up = mimer.get_fcr_d_up_prices()
    prices_fcr_d_down = mimer.get_fcr_d_down_prices()

    nice_price_output(
        prices = prices_fcr_n,
        prices_sum = mimer.get_sum_prices(prices_fcr_n),
        description = 'FCR-N'
    )

    nice_price_output(
        prices = prices_fcr_d_up,
        prices_sum = mimer.get_sum_prices(prices_fcr_d_up),
        description = 'FCR-D UP'
    )

    nice_price_output(
        prices = prices_fcr_d_down,
        prices_sum = mimer.get_sum_prices(prices_fcr_d_down),
        description = 'FCR-D DOWN'
    )

if __name__ == '__main__':
    asyncio.run(main())

Output

+-----------------------+----------------------+
|  Date                 |  FCR-N Price (SEK)   |
+-----------------------+----------------------+
|  2023-09-01 00:00:00  |  5.486731094065      |
|  2023-09-01 01:00:00  |  5.473278975271923   |
|  2023-09-01 02:00:00  |  5.483046953399573   |
|  2023-09-01 03:00:00  |  6.024919011768675   |
|  2023-09-01 04:00:00  |  6.104584800746637   |
|  2023-09-01 05:00:00  |  5.986810670706285   |
|  2023-09-01 06:00:00  |  5.294082266137055   |
|  2023-09-01 07:00:00  |  5.916679569335204   |
|  2023-09-01 08:00:00  |  5.313394297072511   |
|  2023-09-01 09:00:00  |  5.348831037548244   |
|  2023-09-01 10:00:00  |  5.9203287697025315  |
|  2023-09-01 11:00:00  |  5.135825881194346   |
|  2023-09-01 12:00:00  |  5.444676166159138   |
|  2023-09-01 13:00:00  |  5.870019916245568   |
|  2023-09-01 14:00:00  |  5.850853828046824   |
|  2023-09-01 15:00:00  |  5.273275331522941   |
|  2023-09-01 16:00:00  |  5.797683169549086   |
|  2023-09-01 17:00:00  |  5.319454888932867   |
|  2023-09-01 18:00:00  |  5.611263498677803   |
|  2023-09-01 19:00:00  |  5.239250943858182   |
|  2023-09-01 20:00:00  |  5.93201670243       |
|  2023-09-01 21:00:00  |  5.210278111126205   |
|  2023-09-01 22:00:00  |  5.133704096332981   |
|  2023-09-01 23:00:00  |  5.356158378649376   |
|  Total                |  133.52714835847897  |
+-----------------------+----------------------+
+-----------------------+------------------------+
|  Date                 |  FCR-D UP Price (SEK)  |
+-----------------------+------------------------+
|  2023-09-01 00:00:00  |  3.311632998865711     |
|  2023-09-01 01:00:00  |  3.288935554512015     |
|  2023-09-01 02:00:00  |  3.213295847960331     |
|  2023-09-01 03:00:00  |  3.3367902114671084    |
|  2023-09-01 04:00:00  |  3.398391009694043     |
|  2023-09-01 05:00:00  |  3.3220856146399993    |
|  2023-09-01 06:00:00  |  3.57437562248         |
|  2023-09-01 07:00:00  |  3.3276878273599997    |
|  2023-09-01 08:00:00  |  3.5360363853152434    |
|  2023-09-01 09:00:00  |  3.3858881034742017    |
|  2023-09-01 10:00:00  |  3.4942032289633813    |
|  2023-09-01 11:00:00  |  3.4234401975693007    |
|  2023-09-01 12:00:00  |  3.398380667428867     |
|  2023-09-01 13:00:00  |  3.4784308005587947    |
|  2023-09-01 14:00:00  |  3.467791909074881     |
|  2023-09-01 15:00:00  |  3.356563749603953     |
|  2023-09-01 16:00:00  |  3.4768104629727423    |
|  2023-09-01 17:00:00  |  3.3993578147653962    |
|  2023-09-01 18:00:00  |  3.4107899648525573    |
|  2023-09-01 19:00:00  |  3.399232440138542     |
|  2023-09-01 20:00:00  |  3.26405194036575      |
|  2023-09-01 21:00:00  |  3.3716430111448683    |
|  2023-09-01 22:00:00  |  3.287736021089064     |
|  2023-09-01 23:00:00  |  3.3028224861553075    |
|  Total                |  81.22637387045205     |
+-----------------------+------------------------+
+-----------------------+--------------------------+
|  Date                 |  FCR-D DOWN Price (SEK)  |
+-----------------------+--------------------------+
|  2023-09-01 00:00:00  |  6.320488106056495       |
|  2023-09-01 01:00:00  |  6.112997699823686       |
|  2023-09-01 02:00:00  |  6.134507849844338       |
|  2023-09-01 03:00:00  |  6.499827573714409       |
|  2023-09-01 04:00:00  |  6.844614022955501       |
|  2023-09-01 05:00:00  |  6.503989107457241       |
|  2023-09-01 06:00:00  |  5.819638910411214       |
|  2023-09-01 07:00:00  |  5.3365174089495655      |
|  2023-09-01 08:00:00  |  5.884750472026569       |
|  2023-09-01 09:00:00  |  5.607872638348425       |
|  2023-09-01 10:00:00  |  6.010793589290964       |
|  2023-09-01 11:00:00  |  5.860842833901714       |
|  2023-09-01 12:00:00  |  5.903521302210824       |
|  2023-09-01 13:00:00  |  5.986418718780103       |
|  2023-09-01 14:00:00  |  5.638328690026532       |
|  2023-09-01 15:00:00  |  5.50365199491099        |
|  2023-09-01 16:00:00  |  6.00273359520028        |
|  2023-09-01 17:00:00  |  5.799405263827196       |
|  2023-09-01 18:00:00  |  6.062401602087815       |
|  2023-09-01 19:00:00  |  5.780730776740605       |
|  2023-09-01 20:00:00  |  6.2497822237014375      |
|  2023-09-01 21:00:00  |  5.658725413145366       |
|  2023-09-01 22:00:00  |  5.317705775310582       |
|  2023-09-01 23:00:00  |  6.1910944685587         |
|  Total                |  143.03134003728056      |
+-----------------------+--------------------------+

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

aiosvkmimer-0.1.14.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

aiosvkmimer-0.1.14-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file aiosvkmimer-0.1.14.tar.gz.

File metadata

  • Download URL: aiosvkmimer-0.1.14.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for aiosvkmimer-0.1.14.tar.gz
Algorithm Hash digest
SHA256 a3d2a8a095432565261822563315d3a530665804b9be84f919639ff82cd6a7d8
MD5 334c8a87a527e1e9ade08e5f215d6594
BLAKE2b-256 46360cc512b4d2ab6e6522e5854389c6e3ce1e98c77d6ff2f1b2fcd9e629b572

See more details on using hashes here.

File details

Details for the file aiosvkmimer-0.1.14-py3-none-any.whl.

File metadata

  • Download URL: aiosvkmimer-0.1.14-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for aiosvkmimer-0.1.14-py3-none-any.whl
Algorithm Hash digest
SHA256 36bb2cf5d4d4891163b2ffab3e053f1819c06c9258f998ccd4ef9f002b906128
MD5 102cad182851cbc6e417be771f277c98
BLAKE2b-256 6507a794d0e9b35c66b8beb17e41d839d6bc5641203427f5464b02b2792ac2be

See more details on using hashes here.

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