-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathtest_api.py
37 lines (27 loc) · 1.05 KB
/
test_api.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""Run an example script to quickly test."""
import asyncio
import logging
from aiohttp import ClientSession
from pytile import async_login
from pytile.errors import TileError
_LOGGER = logging.getLogger(__name__)
TILE_EMAIL = "<EMAIL>"
TILE_PASSWORD = "<PASSWORD>" # noqa: S105
async def main() -> None:
"""Run."""
logging.basicConfig(level=logging.INFO)
async with ClientSession() as session:
try:
api = await async_login(TILE_EMAIL, TILE_PASSWORD, session)
tiles = await api.async_get_tiles()
_LOGGER.info("Tile Count: %s", len(tiles))
for tile in tiles.values():
_LOGGER.info("UUID: %s", tile.uuid)
_LOGGER.info("Name: %s", tile.name)
_LOGGER.info("Type: %s", tile.kind)
_LOGGER.info("Latitude: %s", tile.latitude)
_LOGGER.info("Longitude: %s", tile.longitude)
_LOGGER.info("Last Timestamp: %s", tile.last_timestamp)
except TileError as err:
_LOGGER.info(err)
asyncio.run(main())