当前位置: 首页>>代码示例>>Python>>正文


Python WebOsClient.register方法代码示例

本文整理汇总了Python中pylgtv.WebOsClient.register方法的典型用法代码示例。如果您正苦于以下问题:Python WebOsClient.register方法的具体用法?Python WebOsClient.register怎么用?Python WebOsClient.register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylgtv.WebOsClient的用法示例。


在下文中一共展示了WebOsClient.register方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setup_tv

# 需要导入模块: from pylgtv import WebOsClient [as 别名]
# 或者: from pylgtv.WebOsClient import register [as 别名]
def setup_tv(host, name, customize, hass, add_devices):
    """Setup a phue bridge based on host parameter."""
    from pylgtv import WebOsClient
    from pylgtv import PyLGTVPairException

    client = WebOsClient(host)

    if not client.is_registered():
        if host in _CONFIGURING:
            # Try to pair.
            try:
                client.register()
            except PyLGTVPairException:
                _LOGGER.warning(
                    "Connected to LG WebOS TV at %s but not paired", host)
                return
            except OSError:
                _LOGGER.error("Unable to connect to host %s", host)
                return
        else:
            # Not registered, request configuration.
            _LOGGER.warning('LG WebOS TV at %s needs to be paired.', host)
            request_configuration(host, name, customize, hass, add_devices)
            return

    # If we came here and configuring this host, mark as done.
    if client.is_registered() and host in _CONFIGURING:
        request_id = _CONFIGURING.pop(host)
        configurator = get_component('configurator')
        configurator.request_done(request_id)

    add_devices([LgWebOSDevice(host, name, customize)])
开发者ID:Bart274,项目名称:home-assistant,代码行数:34,代码来源:webostv.py

示例2: setup_tv

# 需要导入模块: from pylgtv import WebOsClient [as 别名]
# 或者: from pylgtv.WebOsClient import register [as 别名]
def setup_tv(host, mac, name, customize, config, hass, add_devices):
    """Set up a LG WebOS TV based on host parameter."""
    from pylgtv import WebOsClient
    from pylgtv import PyLGTVPairException
    from websockets.exceptions import ConnectionClosed

    client = WebOsClient(host, config)

    if not client.is_registered():
        if host in _CONFIGURING:
            # Try to pair.
            try:
                client.register()
            except PyLGTVPairException:
                _LOGGER.warning(
                    "Connected to LG webOS TV %s but not paired", host)
                return
            except (OSError, ConnectionClosed, TypeError,
                    asyncio.TimeoutError):
                _LOGGER.error("Unable to connect to host %s", host)
                return
        else:
            # Not registered, request configuration.
            _LOGGER.warning("LG webOS TV %s needs to be paired", host)
            request_configuration(
                host, mac, name, customize, config, hass, add_devices)
            return

    # If we came here and configuring this host, mark as done.
    if client.is_registered() and host in _CONFIGURING:
        request_id = _CONFIGURING.pop(host)
        configurator = get_component('configurator')
        configurator.request_done(request_id)

    add_devices([LgWebOSDevice(host, mac, name, customize, config)], True)
开发者ID:Khabi,项目名称:home-assistant,代码行数:37,代码来源:webostv.py

示例3: get_service

# 需要导入模块: from pylgtv import WebOsClient [as 别名]
# 或者: from pylgtv.WebOsClient import register [as 别名]
def get_service(hass, config):
    """Return the notify service."""
    if not validate_config({DOMAIN: config}, {DOMAIN: [CONF_HOST, CONF_NAME]},
                           _LOGGER):
        return None

    host = config.get(CONF_HOST, None)

    if not host:
        _LOGGER.error('No host provided.')
        return None

    from pylgtv import WebOsClient
    from pylgtv import PyLGTVPairException

    client = WebOsClient(host)

    try:
        client.register()
    except PyLGTVPairException:
        _LOGGER.error('Pairing failed.')
        return None
    except ConnectionRefusedError:
        _LOGGER.error('Host unreachable.')
        return None

    return LgWebOSNotificationService(client)
开发者ID:1lann,项目名称:home-assistant,代码行数:29,代码来源:webostv.py

示例4: get_service

# 需要导入模块: from pylgtv import WebOsClient [as 别名]
# 或者: from pylgtv.WebOsClient import register [as 别名]
def get_service(hass, config):
    """Return the notify service."""
    from pylgtv import WebOsClient
    from pylgtv import PyLGTVPairException

    client = WebOsClient(config.get(CONF_HOST))

    try:
        client.register()
    except PyLGTVPairException:
        _LOGGER.error("Pairing with TV failed")
        return None
    except OSError:
        _LOGGER.error("TV unreachable")
        return None

    return LgWebOSNotificationService(client)
开发者ID:DavidLP,项目名称:home-assistant,代码行数:19,代码来源:webostv.py

示例5: get_service

# 需要导入模块: from pylgtv import WebOsClient [as 别名]
# 或者: from pylgtv.WebOsClient import register [as 别名]
def get_service(hass, config, discovery_info=None):
    """Return the notify service."""
    from pylgtv import WebOsClient
    from pylgtv import PyLGTVPairException

    path = hass.config.path(config.get(CONF_FILENAME))
    client = WebOsClient(config.get(CONF_HOST), key_file_path=path)

    try:
        client.register()
    except PyLGTVPairException:
        _LOGGER.error("Pairing with TV failed")
        return None
    except OSError:
        _LOGGER.error("TV unreachable")
        return None

    return LgWebOSNotificationService(client)
开发者ID:arjenfvellinga,项目名称:home-assistant,代码行数:20,代码来源:webostv.py


注:本文中的pylgtv.WebOsClient.register方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。