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


Python WebOsClient.is_registered方法代码示例

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


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

示例1: setup_tv

# 需要导入模块: from pylgtv import WebOsClient [as 别名]
# 或者: from pylgtv.WebOsClient import is_registered [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 is_registered [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 is_registered [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)

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

    return LgWebOSNotificationService(client, config.get(CONF_ICON))
开发者ID:nunofgs,项目名称:home-assistant,代码行数:21,代码来源:webostv.py


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