Skip to main content

Asynchronous Python API For Taipit Cloud Meters

Project description

aioTaipit

Asynchronous Python API for Taipit cloud meters.

Installation

Use pip to install the library:

pip install aiotaipit

Usage

import asyncio
from pprint import pprint

import aiohttp

from aiotaipit import SimpleTaipitAuth, TaipitApi


async def main(username: str, password: str) -> None:
    """Create the aiohttp session and run the example."""
    async with aiohttp.ClientSession() as session:
        auth = SimpleTaipitAuth(username, password, session)
        api = TaipitApi(auth)

        meters = await api.async_get_meters()

        pprint(meters)


if __name__ == "__main__":
    _username = "<YOUR_USER_NAME>"
    _password = "<YOUR_PASSWORD>"
    asyncio.run(main(_username, _password))

The SimpleTaipitAuth client also accept custom client ID and secret (this can be found by sniffing the client).

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

[{'address': 'Санкт-Петербург, Ворошилова, 2',
  'category': 0,
  'ecometerdata': {'P_aver': 0.21986280758339,
                   'P_averSmall': 0.15261778589793,
                   'P_averSmall_': 109.88480584651,
                   'P_aver_': 158.30122146004,
                   'P_aver_TF1': False,
                   'P_aver_TF2': False,
                   'P_aver_TF31': False,
                   'P_aver_TF32': False,
                   'P_aver_TF33': False,
                   'P_norm': 0.0066666666666667,
                   'currentTS': 1671485359,
                   'ecoStatus': None,
                   'lastReading': {'energy_a': 1004.85,
                                   'energy_t1_a': 794.45,
                                   'energy_t2_a': 210.4,
                                   'energy_t3_a': 0,
                                   'ts_tz': 1671483628,
                                   'value': 0.02},
                   'meterCategory': 0,
                   'time': 1671485359,
                   'timezone': 3,
                   'trend': -48.41641561353,
                   'trendTF1': False,
                   'trendTF2': False},
  'id': 2147485997,
  'isLowDataFreq': False,
  'isOwner': False,
  'isVirtual': 0,
  'metername': 'НЕВА МТ 114 (Wi-Fi) (22001110)',
  'owner': {'peopleNumber': None, 'type': 0, 'typeCode': 'person'},
  'serialNumber': '22001110',
  'usericopath': '/uploads/user/photo/3edba895933a54540fbdb88614f24f480a9eeb68.png',
  'username': 'Компания Тайпит',
  'waterHot': False},
 {'address': 'Санкт-Петербург, Ворошилова, 2',
  'category': 0,
  'ecometerdata': {'P_aver': 0.25422232030182,
                   'P_averSmall': 0.2494024938596,
                   'P_averSmall_': 179.56979557891,
                   'P_aver_': 183.04007061731,
                   'P_aver_TF1': False,
                   'P_aver_TF2': False,
                   'P_aver_TF31': False,
                   'P_aver_TF32': False,
                   'P_aver_TF33': False,
                   'P_norm': 0,
                   'currentTS': 1671485359,
                   'ecoStatus': None,
                   'lastReading': {'energy_a': 11595.62,
                                   'energy_t1_a': 10420.94,
                                   'energy_t2_a': 1174.68,
                                   'energy_t3_a': 0,
                                   'ts_tz': 1671483641,
                                   'value': 0},
                   'meterCategory': 0,
                   'time': 1671485359,
                   'timezone': 3,
                   'trend': -3.4702750384005,
                   'trendTF1': False,
                   'trendTF2': False},
  'id': 2147485996,
  'isLowDataFreq': False,
  'isOwner': False,
  'isVirtual': 0,
  'metername': 'НЕВА МТ 114 (Wi-Fi) (22001114)',
  'owner': {'peopleNumber': None, 'type': 0, 'typeCode': 'person'},
  'serialNumber': '22001114',
  'usericopath': '/uploads/user/photo/3edba895933a54540fbdb88614f24f480a9eeb68.png',
  'username': 'Компания Тайпит',
  'waterHot': False}]

Timeouts

aiotaipit 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):
    all_readings = await api.async_get_meters()

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

aiotaipit-2.2.0.tar.gz (31.1 kB view details)

Uploaded Source

Built Distribution

aiotaipit-2.2.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file aiotaipit-2.2.0.tar.gz.

File metadata

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

File hashes

Hashes for aiotaipit-2.2.0.tar.gz
Algorithm Hash digest
SHA256 12671a0acc9ebdd52b46ee88483553890b82bd5daddda96e37afb7f17dc2fd54
MD5 eb95f821946f1969ea31e9b16bd839f5
BLAKE2b-256 cb37fef6abd5b81640a9f85c27591a4b19a1cf3aa886523ad8153c8205309eea

See more details on using hashes here.

File details

Details for the file aiotaipit-2.2.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for aiotaipit-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4da3ac06fd0da5ec0826562c5fea74189804a3ad03a704a25d33bf62e11eed91
MD5 92366e919c64d16ba42bfe35fa22d1e6
BLAKE2b-256 bad5f98ddfb38f6eefd894af20c2caaa485122fd7fcd478de4b4b799625cbcc3

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