How to use the pydeconz.DeconzSession function in pydeconz

To help you get started, we’ve selected a few pydeconz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kane610 / deconz / tests / test_init.py View on Github external
def session() -> DeconzSession:
    """Returns the session object."""
    session = Mock()
    return DeconzSession(session, IP, PORT, API_KEY)
github home-assistant / home-assistant / homeassistant / components / deconz / gateway.py View on Github external
async def get_gateway(
    hass, config, async_add_device_callback, async_connection_status_callback
) -> DeconzSession:
    """Create a gateway object and verify configuration."""
    session = aiohttp_client.async_get_clientsession(hass)

    deconz = DeconzSession(
        session,
        config[CONF_HOST],
        config[CONF_PORT],
        config[CONF_API_KEY],
        async_add_device=async_add_device_callback,
        connection_status=async_connection_status_callback,
    )
    try:
        with async_timeout.timeout(10):
            await deconz.initialize()
        return deconz

    except errors.Unauthorized:
        _LOGGER.warning("Invalid key for deCONZ at %s", config[CONF_HOST])
        raise AuthenticationRequired
github Kane610 / deconz / pydeconz / __main__.py View on Github external
async def main(loop, **kwargs):
    """
    """
    if "api_key" not in kwargs:
        api_key = await async_get_api_key(loop, **kwargs)
        kwargs["api_key"] = api_key
        print(api_key)
    websession = aiohttp.ClientSession(loop=loop)
    deconz = DeconzSession(loop, websession, **kwargs)
    result = await deconz.async_load_parameters()
    if result is False:
        print("Failed to setup deCONZ")
        return False
    deconz.start()
    from pprint import pprint

    pprint(deconz.__dict__)
    # await deconz.async_delete_state('/lights/2/groups', {'reset':'true'})