aiotnse


Nameaiotnse JSON
Version 1.3.0 PyPI version JSON
download
home_page
SummaryAsynchronous Python API For TNS-Energo
upload_time2024-02-27 12:10:07
maintainer
docs_urlNone
authorLizardSystems
requires_python>=3.9.0
licenseMIT License
keywords tns-energo energy electricity
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # aioTNSE

Asynchronous Python API for [TNS-Energo](https://tns-e.ru).

## Installation

Use pip to install the library:

```commandline
pip install aiotnse
```

## Usage

```python

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:

```json
{
  "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:

```python
import asyncio

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

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "aiotnse",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9.0",
    "maintainer_email": "",
    "keywords": "tns-energo,energy,electricity",
    "author": "LizardSystems",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/78/77/16da4aa602702c637d05e740f9b34f2de591d86191b7546e8447626e7beb/aiotnse-1.3.0.tar.gz",
    "platform": "any",
    "description": "# aioTNSE\n\nAsynchronous Python API for [TNS-Energo](https://tns-e.ru).\n\n## Installation\n\nUse pip to install the library:\n\n```commandline\npip install aiotnse\n```\n\n## Usage\n\n```python\n\nimport asyncio\nfrom pprint import pprint\n\nimport aiohttp\n\nfrom aiotnse import SimpleTNSEAuth, TNSEApi\n\n\nasync def main(account: str) -> None:\n    \"\"\"Create the aiohttp session and run the example.\"\"\"\n    async with aiohttp.ClientSession() as session:\n        auth = SimpleTNSEAuth(session)\n        api = TNSEApi(auth)\n\n        data = await api.async_get_latest_readings(account)\n\n        pprint(data)\n\n\nif __name__ == \"__main__\":\n    _account = string = str(input(\"Account: \"))\n    asyncio.run(main(_account))\n```\n\nThe `SimpleTNSEAuth` client also accept custom access token (this can be found by sniffing the client).\n\nThis will return a price object that looks a little like this:\n\n```json\n{\n  \"STATUS\": \"\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f\",\n  \"counters\": {\n    \"1111111\": [\n      {\n        \"Can_delete\": \"0\",\n        \"DatePok\": \"06.02.2023\",\n        \"DatePosledPover\": \"31.12.2021\",\n        \"DatePover\": \"31.12.2037\",\n        \"DatePoverStatus\": 0,\n        \"DatePoverURL\": \"\",\n        \"GodVipuska\": \"01.01.22\",\n        \"KoefTrans\": \"1\",\n        \"Label\": \"\u0414\u043d\u0435\u0432\u043d\u0430\u044f \u0437\u043e\u043d\u0430\",\n        \"MaxPok\": \"2000\",\n        \"MestoUst\": \"\u0416\u0438\u043b\u043e\u0439 \u0434\u043e\u043c\",\n        \"ModelPU\": \"\u041d\u0435\u0432\u0430 \u041c\u0422 114 AS PLRFPC\",\n        \"NazvanieTarifa\": \"\u0414\u0435\u043d\u044c\",\n        \"NazvanieUslugi\": \"\u042d\u043b\u0435\u043a\u0442\u0440\u043e\u0441\u043d\u0430\u0431\u0436\u0435\u043d\u0438\u0435 \",\n        \"NomerTarifa\": \"0\",\n        \"NomerUslugi\": \"0100\",\n        \"PredPok\": \"700\",\n        \"RaschSch\": \"\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442\",\n        \"Razradnost\": \"6\",\n        \"RowID\": \"1111111\",\n        \"Tarifnost\": \"2\",\n        \"Type\": \"1\",\n        \"ZavodNomer\": \"22222222\",\n        \"sort\": 0,\n        \"zakrPok\": \"700\"\n      },\n      {\n        \"Can_delete\": \"0\",\n        \"DatePok\": \"06.02.2023\",\n        \"DatePosledPover\": \"31.12.2021\",\n        \"DatePover\": \"31.12.2037\",\n        \"DatePoverStatus\": 0,\n        \"DatePoverURL\": \"\",\n        \"GodVipuska\": \"01.01.22\",\n        \"KoefTrans\": \"1\",\n        \"Label\": \"\u041d\u043e\u0447\u043d\u0430\u044f \u0437\u043e\u043d\u0430\",\n        \"MaxPok\": \"2000\",\n        \"MestoUst\": \"\u0416\u0438\u043b\u043e\u0439 \u0434\u043e\u043c\",\n        \"ModelPU\": \"\u041d\u0435\u0432\u0430 \u041c\u0422 114 AS PLRFPC\",\n        \"NazvanieTarifa\": \"\u041d\u043e\u0447\u044c\",\n        \"NazvanieUslugi\": \"\u042d\u043b\u0435\u043a\u0442\u0440\u043e\u0441\u043d\u0430\u0431\u0436\u0435\u043d\u0438\u0435 \",\n        \"NomerTarifa\": \"1\",\n        \"NomerUslugi\": \"0100\",\n        \"PredPok\": \"337\",\n        \"RaschSch\": \"\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442\",\n        \"Razradnost\": \"6\",\n        \"RowID\": \"1111111\",\n        \"Tarifnost\": \"2\",\n        \"Type\": \"1\",\n        \"ZavodNomer\": \"22222222\",\n        \"sort\": 1,\n        \"zakrPok\": \"337\"\n      }\n    ]\n  },\n  \"result\": true\n}\n```\n\n## Timeouts\n\naiotnse 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:\n\n```python\nimport asyncio\n\nwith asyncio.timeout(10):\n    data = await api.async_get_account_status(account)\n```\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Asynchronous Python API For TNS-Energo",
    "version": "1.3.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/lizardsystems/aiotnse/issues",
        "Changelog": "https://github.com/lizardsystems/aiotnse/blob/master/CHANGELOG.md",
        "Documentation": "https://github.com/lizardsystems/aiotnse",
        "Home": "https://github.com/lizardsystems/aiotnse",
        "Repository": "https://github.com/lizardsystems/aiotnse"
    },
    "split_keywords": [
        "tns-energo",
        "energy",
        "electricity"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "23fecb1abe4fdf56b35d0be2233958a7d19cc0ff1039b23b1f05a1000331f3ab",
                "md5": "095cb6c3e07827c48a523824acb9463f",
                "sha256": "3c3987d33fd2cc9c8fdab74e63100c9f2682244d277a5629ea37c3389d359f35"
            },
            "downloads": -1,
            "filename": "aiotnse-1.3.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "095cb6c3e07827c48a523824acb9463f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9.0",
            "size": 10285,
            "upload_time": "2024-02-27T12:10:05",
            "upload_time_iso_8601": "2024-02-27T12:10:05.260515Z",
            "url": "https://files.pythonhosted.org/packages/23/fe/cb1abe4fdf56b35d0be2233958a7d19cc0ff1039b23b1f05a1000331f3ab/aiotnse-1.3.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "787716da4aa602702c637d05e740f9b34f2de591d86191b7546e8447626e7beb",
                "md5": "6f233e58df62ab5ab2daef57db796760",
                "sha256": "1bc89033a667244ef97cd49142feae88e95ccb70d0233cc861575b447bcc3635"
            },
            "downloads": -1,
            "filename": "aiotnse-1.3.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6f233e58df62ab5ab2daef57db796760",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9.0",
            "size": 17291,
            "upload_time": "2024-02-27T12:10:07",
            "upload_time_iso_8601": "2024-02-27T12:10:07.093361Z",
            "url": "https://files.pythonhosted.org/packages/78/77/16da4aa602702c637d05e740f9b34f2de591d86191b7546e8447626e7beb/aiotnse-1.3.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-27 12:10:07",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lizardsystems",
    "github_project": "aiotnse",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "aiotnse"
}
        
Elapsed time: 3.21094s