pnbruckner / life360

A simple python life360 client
MIT License
16 stars 6 forks source link

Example Call for beta version #17

Closed ryanbuckner closed 2 months ago

ryanbuckner commented 2 months ago

Would you mind updating the read.me with a sample of how to use / test this new beta? I think logging in and printing a list of members would be sufficient.

pnbruckner commented 2 months ago

I've never intended this package for "standalone" usage. It was intended for use by a Home Assistant integration. If someone can use it for other purposes, and can figure out how to do so, by all means. I don't plan on improving the docs to that end.

Having said that, you can look here for how the HA integration I'm working on uses it:

https://github.com/pnbruckner/ha-life360/blob/ede302c06652ddda524657fb40fc52e16e8bc1b9/custom_components/life360/coordinator.py#L567-L573

ryanbuckner commented 2 months ago

Understood. Thanks for all you're doing.

pnbruckner commented 2 months ago

Here's also a snippet from a test script I wrote:

import asyncio

from aiohttp import ClientSession, ClientTimeout
from life360 import Life360

USERNAME = "someone@someplace.com"
PASSWORD = "someones_password"
MAX_RETRIES = 2
VERBOSITY = 4

async def main():
    session = ClientSession(timeout=ClientTimeout(15))
    try:
        api = Life360(session, MAX_RETRIES, verbosity=VERBOSITY)
        authorization = await api.login_by_username(USERNAME, PASSWORD)
        # Save authorization for future use if desired.
        # It can be passed into the Life360 constructor and then login_by_username isn't necessary.
        circles = api.get_circles()
        # ...
    finally:
        await session.close()

asyncio.run(main())
ryanbuckner commented 2 months ago

This is working for me, thank you