async def main(): """Sample code to retrieve the data from an UPC Connect Box.""" async with aiohttp.ClientSession() as session: client = ConnectBox(loop, session) # Print details about the connected devices await client.async_get_devices() print(client.data)
async def get_cmstatus(host, password): async with aiohttp.ClientSession() as session: client = ConnectBox(session=session, host=host, password=password) await client.async_get_cmstatus_and_service_flows() await client.async_close_session() return { 'cmstatus': client.cmstatus, 'downstream_service_flows': client.downstream_service_flows, 'upstream_service_flows': client.upstream_service_flows }
async def main(): while True: async with aiohttp.ClientSession() as session: client = ConnectBox(session, ROUTERPASSWORD) # Print details about the connected devices await client.async_get_devices() # pprint(client.devices) report(client.devices) await client.async_close_session()
async def async_get_scanner(config, session): """Return the UPC device scanner.""" connect_box = ConnectBox(session, config[CONF_PASSWORD], host=config[CONF_HOST]) # Check login data try: await connect_box.async_initialize_token() except ConnectBoxLoginError: _LOGGER.error("ConnectBox login data error!") return None except ConnectBoxError: pass return UPCDeviceScanner(connect_box)
async def main(): """Sample code to retrieve the data from an UPC Connect Box.""" async with aiohttp.ClientSession() as session: client = ConnectBox(session, "password") # Print details about the downstream channel connectivity await client.async_get_downstream() pprint(client.ds_channels) # Print details about the upstream channel connectivity await client.async_get_upstream() pprint(client.us_channels) # Print details about the connected devices await client.async_get_devices() pprint(client.devices)
async def main(): """Sample code to retrieve the data from an UPC Connect Box.""" async with aiohttp.ClientSession() as session: client = ConnectBox(session, PASSWORD) # Print details about the downstream channel connectivity await client.async_get_downstream() pprint(client.ds_channels) # Print details about the upstream channel connectivity await client.async_get_upstream() pprint(client.us_channels) # Print details about the connected devices await client.async_get_devices() pprint(client.devices) # Print IPv6 filter rules # (IPv6 required) await client.async_get_ipv6_filtering() pprint(client.ipv6_filters) # Toggle enable/disable on the first IPv6 filter rule new_value = await client.async_toggle_ipv6_filter(1) # Show the effect await client.async_get_ipv6_filtering() pprint(client.ipv6_filters) # Print details on general device status await client.async_get_cmstatus_and_service_flows() pprint(client.cmstatus) pprint(client.downstream_service_flows) pprint(client.upstream_service_flows) # Print temperature status await client.async_get_temperature() pprint(client.temperature) # Print event log entries await client.async_get_eventlog() pprint(client.eventlog) await client.async_close_session()
async def async_get_scanner(hass, config): """Return the UPC device scanner.""" conf = config[DOMAIN] session = hass.helpers.aiohttp_client.async_get_clientsession() connect_box = ConnectBox(session, conf[CONF_PASSWORD], host=conf[CONF_HOST]) # Check login data try: await connect_box.async_initialize_token() except ConnectBoxLoginError: _LOGGER.error("ConnectBox login data error!") return None except ConnectBoxError: pass async def _shutdown(event): """Shutdown event.""" await connect_box.async_close_session() hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, _shutdown) return UPCDeviceScanner(connect_box)
async def toggle_ipv6filter(host, password, idd): async with aiohttp.ClientSession() as session: client = ConnectBox(session=session, host=host, password=password) new_value = await client.async_toggle_ipv6_filter(idd) await client.async_close_session() return new_value
async def get_ipv6filters(host, password): async with aiohttp.ClientSession() as session: client = ConnectBox(session=session, host=host, password=password) await client.async_get_ipv6_filtering() await client.async_close_session() return client.ipv6_filters
async def get_temperature(host, password): async with aiohttp.ClientSession() as session: client = ConnectBox(session=session, host=host, password=password) await client.async_get_temperature() await client.async_close_session() return client.temperature
async def get_upstream(host, password): async with aiohttp.ClientSession() as session: client = ConnectBox(session=session, host=host, password=password) await client.async_get_upstream() await client.async_close_session() return client.us_channels
async def get_downstream(host, password): async with aiohttp.ClientSession() as session: client = ConnectBox(session=session, host=host, password=password) await client.async_get_devices() await client.async_close_session() return client.devices