Skip to content

Commit b6c44d9

Browse files
committed
Small project improvementspoetry
1 parent 0aa6b31 commit b6c44d9

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

examples/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""PyMelcloud examples."""

examples/example.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""Asynchronous Python client for MELCloud. This is an example file."""
2+
3+
import asyncio
4+
import logging
5+
6+
import aiohttp
7+
import pymelcloud
8+
9+
logging.basicConfig(level=logging.INFO)
10+
logger = logging.getLogger(__name__)
11+
12+
13+
async def main() -> None:
14+
"""Demonstrate the usage of pymelcloud.
15+
16+
This function logs in to the MELCloud service, retrieves a list of devices,
17+
and performs operations on a specific device. It uses an asynchronous
18+
HTTP session for communication.
19+
20+
Raises
21+
------
22+
ValueError: If login fails due to invalid credentials or other issues.
23+
"""
24+
async with aiohttp.ClientSession() as session:
25+
try:
26+
# Call the login method with the session
27+
token = await pymelcloud.login(
28+
"[email protected]", "mysecretpassword", session=session
29+
)
30+
logger.info("Login successful, token: %s", token)
31+
except ValueError:
32+
logger.exception("Login failed")
33+
return
34+
35+
# Lookup the device
36+
devices = await pymelcloud.get_devices(token, session=session)
37+
device = devices[pymelcloud.DEVICE_TYPE_ATW][0]
38+
39+
# Perform logic on the device
40+
await device.update()
41+
42+
logger.info("Device name: %s", device.name)
43+
await session.close()
44+
45+
46+
if __name__ == "__main__":
47+
asyncio.run(main())

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ignore-imports = true
107107
max-line-length = 88
108108

109109
[tool.pytest.ini_options]
110-
addopts = "--cov"
110+
addopts = "--cov --cov-fail-under=60" # Fice for now, since this is how the project was inherited
111111
asyncio_mode = "auto"
112112

113113
[tool.ruff]

0 commit comments

Comments
 (0)