Skip to main content

Asynchronous Python API For TNS-Energo

Project description

aioTNSE

Asynchronous Python API for TNS-Energo.

Installation

Use pip to install the library:

pip install aiotnse

Usage

import asyncio
from pprint import pprint

import aiohttp

from aiotnse import SimpleTNSEAuth, TNSEApi


async def main(account: str) -> None:
    """Create the aiohttp session and run the example."""
    async with aiohttp.ClientSession() as session:
        auth = SimpleTNSEAuth(session)
        api = TNSEApi(auth)

        data = await api.async_get_latest_readings(account)

        pprint(data)


if __name__ == "__main__":
    _account = string = str(input("Account: "))
    asyncio.run(main(_account))

The SimpleTNSEAuth client also accept custom access token (this can be found by sniffing the client).

This will return a price object that looks a little like this:

{
  "STATUS": "Используется",
  "counters": {
    "1111111": [
      {
        "Can_delete": "0",
        "DatePok": "06.02.2023",
        "DatePosledPover": "31.12.2021",
        "DatePover": "31.12.2037",
        "DatePoverStatus": 0,
        "DatePoverURL": "",
        "GodVipuska": "01.01.22",
        "KoefTrans": "1",
        "Label": "Дневная зона",
        "MaxPok": "2000",
        "MestoUst": "Жилой дом",
        "ModelPU": "Нева МТ 114 AS PLRFPC",
        "NazvanieTarifa": "День",
        "NazvanieUslugi": "Электроснабжение ",
        "NomerTarifa": "0",
        "NomerUslugi": "0100",
        "PredPok": "700",
        "RaschSch": "Работает",
        "Razradnost": "6",
        "RowID": "1111111",
        "Tarifnost": "2",
        "Type": "1",
        "ZavodNomer": "22222222",
        "sort": 0,
        "zakrPok": "700"
      },
      {
        "Can_delete": "0",
        "DatePok": "06.02.2023",
        "DatePosledPover": "31.12.2021",
        "DatePover": "31.12.2037",
        "DatePoverStatus": 0,
        "DatePoverURL": "",
        "GodVipuska": "01.01.22",
        "KoefTrans": "1",
        "Label": "Ночная зона",
        "MaxPok": "2000",
        "MestoUst": "Жилой дом",
        "ModelPU": "Нева МТ 114 AS PLRFPC",
        "NazvanieTarifa": "Ночь",
        "NazvanieUslugi": "Электроснабжение ",
        "NomerTarifa": "1",
        "NomerUslugi": "0100",
        "PredPok": "337",
        "RaschSch": "Работает",
        "Razradnost": "6",
        "RowID": "1111111",
        "Tarifnost": "2",
        "Type": "1",
        "ZavodNomer": "22222222",
        "sort": 1,
        "zakrPok": "337"
      }
    ]
  },
  "result": true
}

Timeouts

aiotnse does not specify any timeouts for any requests. You will need to specify them in your own code. We recommend the timeout from asyncio package:

import asyncio

with asyncio.timeout(10):
    data = await api.async_get_account_status(account)

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

aiotnse-1.3.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

aiotnse-1.3.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file aiotnse-1.3.0.tar.gz.

File metadata

  • Download URL: aiotnse-1.3.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for aiotnse-1.3.0.tar.gz
Algorithm Hash digest
SHA256 1bc89033a667244ef97cd49142feae88e95ccb70d0233cc861575b447bcc3635
MD5 6f233e58df62ab5ab2daef57db796760
BLAKE2b-256 787716da4aa602702c637d05e740f9b34f2de591d86191b7546e8447626e7beb

See more details on using hashes here.

File details

Details for the file aiotnse-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: aiotnse-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for aiotnse-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c3987d33fd2cc9c8fdab74e63100c9f2682244d277a5629ea37c3389d359f35
MD5 095cb6c3e07827c48a523824acb9463f
BLAKE2b-256 23fecb1abe4fdf56b35d0be2233958a7d19cc0ff1039b23b1f05a1000331f3ab

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