Пример #1
0
async def async_setup_tv(hass, config, conf):
    """Set up a LG WebOS TV based on host parameter."""

    host = conf[CONF_HOST]
    config_file = hass.config.path(WEBOSTV_CONFIG_FILE)

    client = WebOsClient(host, config_file)
    hass.data[DOMAIN][host] = {"client": client}

    if client.is_registered():
        await async_setup_tv_finalize(hass, config, conf, client)
    else:
        _LOGGER.warning("LG webOS TV %s needs to be paired", host)
        await async_request_configuration(hass, config, conf, client)
Пример #2
0
def aiopylgtvcommand():
    parser = argparse.ArgumentParser(description="Send command to LG WebOs TV.")
    parser.add_argument(
        "host", type=str, help="hostname or ip address of the TV to connect to"
    )
    parser.add_argument(
        "command",
        type=str,
        help="command to send to the TV (can be any function of WebOsClient)",
    )
    parser.add_argument(
        "parameters",
        type=convert_arg,
        nargs="*",
        help="additional parameters to be passed to WebOsClient function call",
    )

    args = parser.parse_args()

    client = WebOsClient(args.host, timeout_connect=2)

    asyncio.run(runloop(client, args.command, args.parameters))