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-1.0.1.tar.gz
(11.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file citycom_mv_api-1.0.1.tar.gz.
File metadata
- Download URL: citycom_mv_api-1.0.1.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.13 Linux/6.11.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03d341c1127d757e0aba9be1b269bb544aab61422ad015dc88152a7586be9520
|
|
| MD5 |
5b57e509a4eda51a015c064c210d38a5
|
|
| BLAKE2b-256 |
40ae05c9f78dda672fc4fc582ebf637c2c1a68ca380325bb7ebcd19ea9b490d1
|
File details
Details for the file citycom_mv_api-1.0.1-py3-none-any.whl.
File metadata
- Download URL: citycom_mv_api-1.0.1-py3-none-any.whl
- Upload date:
- Size: 18.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.13 Linux/6.11.0-1015-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
23eff44cdad97a06eaddbe29c1c4ca589efa20af2fcf06a1fce6baa7fab14e11
|
|
| MD5 |
bd1c2b29f05468e1a69843cd99f4d79d
|
|
| BLAKE2b-256 |
108c462d54dbcdbbd7d4749d00da5a82803dfb0104ae294372a013825000c428
|