A Python wrapper for citycom-mv water meters api
Project description
citycom_mv_api
A python wrapper for citycom_mv api
Module Usage
import asyncio
import os
import aiohttp
from loguru import logger
from citycom_mv_api.citycom_mv_client import CityComMVClient
from citycom_mv_api.login import LoginError
from citycom_mv_api.models.exceptions import CitycomError
session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False), timeout=aiohttp.ClientTimeout(total=10))
try:
# Example of usage
client = CityComMVClient("XXXX@citycom-mv.com", "YYY", session)
token_json_file = "token.json"
if os.path.exists(token_json_file):
await client.load_token_from_file(token_json_file)
else:
try:
await client.login()
await client.save_token_to_file(token_json_file)
except LoginError as err:
logger.error(f"Failed Login: (Code {err.code}): {err.error}")
raise
# refresh token example- currently not implemented, it just logins again
token = client.get_token()
await client.check_token()
new_token = client.get_token()
if token != new_token:
print("Token refreshed")
await client.save_token_to_file(token_json_file)
print("access_token: " + token.access_token)
customer = await client.get_customer()
print(customer)
reading = await client.get_last_meter_reading(customer.properties[0].meters[0].meter_id)
print(reading)
except CitycomError as err:
logger.error(f"Error: (Code {err.code}): {err.error}")
finally:
await session.close()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
citycom_mv_api-0.1.3.tar.gz
(11.6 kB
view hashes)
Built Distribution
Close
Hashes for citycom_mv_api-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7e66951a74448e8373e0a21ff31d67841fa5f30d7569bc23cc04b01e3b210de |
|
MD5 | 0d830932782e2e136c959df532028f58 |
|
BLAKE2b-256 | cae4f3ae47706bf373e66fb4db406eb0cc0e1676d3e9c4dccd4625fa3c4be375 |