예제 #1
0
def setup(hass, config):
    """Set up the Lyric component."""
    import lyric

    if 'lyric' in _CONFIGURING:
        return

    conf = config[DOMAIN]
    client_id = conf[CONF_CLIENT_ID]
    client_secret = conf[CONF_CLIENT_SECRET]
    cache_ttl = conf[CONF_SCAN_INTERVAL]
    filename = LYRIC_CONFIG_FILE
    token_cache_file = hass.config.path(filename)
    redirect_uri = conf.get(
        CONF_REDIRECT_URI,
        hass.config.api.base_url + '/api/lyric/authenticate')

    lyric = lyric.Lyric(token_cache_file=token_cache_file,
                        client_id=client_id,
                        client_secret=client_secret,
                        app_name='Home Assistant',
                        redirect_uri=redirect_uri,
                        cache_ttl=cache_ttl)

    setup_lyric(hass, lyric, config)

    return True
예제 #2
0
import lyric

client_id = r''
client_secret = r''

redirect_uri = 'https://hass.deproducties.com/api/lyric'
app_name = 'Sample'
token_cache_file = 'token.txt'

lapi = lyric.Lyric(client_id=client_id,
                   client_secret=client_secret,
                   token_cache_file=token_cache_file,
                   redirect_uri=redirect_uri,
                   app_name=app_name)

if lapi._token is None:
    print(lapi.getauthorize_url)

print(lapi._locations)

for location in lapi.locations:
    print(location)
    print(location.id)
    print(location.name)
    print(location.city)
    print(location.geoFences)
    print(location.geoFences[0]['geoOccupancy']['withinFence'])

    for user in location.users:
        print(user)
        print(user.id)