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.2.tar.gz
(10.1 kB
view details)
Built Distribution
File details
Details for the file citycom_mv_api-0.1.2.tar.gz
.
File metadata
- Download URL: citycom_mv_api-0.1.2.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.8 Linux/6.5.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c85ffeba25670481363f5a61883208fe138d2ca8949748320fadbd2383f87fb |
|
MD5 | 0e402787eb4c6d06c7bda144ee6b4de7 |
|
BLAKE2b-256 | 923bd11879378eb0a701588786fea9114b5b5d02e729229252e165d325ca343b |
File details
Details for the file citycom_mv_api-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: citycom_mv_api-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.8 Linux/6.5.0-1016-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 703c9f835f8e9d9f3ae0f7e141ab02f3fdbdb81f93490bb8debe59d0824cd2f1 |
|
MD5 | 32d1a5fae2b6bdbb182c9777100acb5f |
|
BLAKE2b-256 | fcf49d1899fe1df1c9b9110bb95408961a4db2e541b43f775ee37a45251d9bec |